How to fix HTTPS-HTTP mixed content error in JSP redirection in a java web application

一笑奈何 提交于 2020-07-10 07:29:09

问题


I am using a DNS url (https) which is a load balancer url for my web application which is hosted in Weblogic server. When I hit the url in chrome and I can do a successful login. Then when I am trying to click on some button from the page , say some view/edit button, there is no response. When I debugged I found it is due to mixed content issue in chrome. Yes I don't face any issue in IE and Firefox for the same.

When I am using the raw http url in stead of the DNS url, I have no issues.

Now, I want to fix this issue in my jsp itself. But I am not sure about the code changes that I need to make.

Following are the URLs that I get from network trace :

Console URL : https://dns-host/myapp/console.jsp
Request URL : https://dns-host/myapp/editWorkSelector.jsp?workid=1234&copywork=view
Referer     : https://dns-host/myapp/workDataScr.jsp?workname=null
Location    : http://dns-host/myapp/workView.jsp

I am trying to go to workView.jsp in my code. Here I face the issue and unable to go to the page.

Here is a sample code :

File : workDataScr.jsp

<td align="center" bgcolor="<%=bgcolor%>">           
    <a href="editWorkSelector.jsp?workid=<%=id%>&copywork=view" 
       onClick="return checkForSystem(this.form,'<%=id%>','<%=type%>','<%=role%>')">VIEW
    </a>
</td>

function checkForSystem(form,workid,worktype,role){
   form = document.forms[1];
   form.action="editWorkSelector.jsp?workid="+workid+"&type="+worktype;
   form.submit();
}

File : editWorkSelector.jsp

 String workid = request.getParameter("workid");
 String copy = (String)request.getParameter("copywork");
 String workname = (String)request.getParameter("workname");
 WorkData work = workBean.getWork(workid);

 response.sendRedirect("workView.jsp");

Here lies the issue, due to mixed content the code flow is unable to reach workView.jsp.

Error :

Mixed Content: The page at 'https://dns-host/myapp/console.jsp' was loaded over HTTPS, 
but requested an insecure resource 'http://dns-host/myapp/workView.jsp'. 
This request has been blocked; the content must be served over HTTPS.
enter code here

It will be very helpful to know how to fix this issue in my code.

来源:https://stackoverflow.com/questions/62434681/how-to-fix-https-http-mixed-content-error-in-jsp-redirection-in-a-java-web-appli

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!