title: How to fix HTTPS-HTTP mixed content error in JSP redirection in a java web application
body: <p>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. </p>
  
  <p>When I am using the raw http url in stead of the DNS url, I have no issues.</p>
  
  <p>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.</p>
  
  <p>Following are the URLs that I get from network trace :</p>
  
  <pre><code>Console URL : https://dns-host/myapp/console.jsp
  Request URL : https://dns-host/myapp/editWorkSelector.jsp?workid=1234&amp;copywork=view
  Referer     : https://dns-host/myapp/workDataScr.jsp?workname=null
  Location    : http://dns-host/myapp/workView.jsp
  </code></pre>
  
  <p>I am trying to go to workView.jsp in my code. Here I face the issue and unable to go to the page.</p>
  
  <p>Here is  a sample code :</p>
  
  <p>File :  workDataScr.jsp</p>
  
  <pre><code>&lt;td align="center" bgcolor="&lt;%=bgcolor%&gt;"&gt;           
      &lt;a href="editWorkSelector.jsp?workid=&lt;%=id%&gt;&amp;copywork=view" 
         onClick="return checkForSystem(this.form,'&lt;%=id%&gt;','&lt;%=type%&gt;','&lt;%=role%&gt;')"&gt;VIEW
      &lt;/a&gt;
  &lt;/td&gt;
  
  function checkForSystem(form,workid,worktype,role){
     form = document.forms[1];
     form.action="editWorkSelector.jsp?workid="+workid+"&amp;type="+worktype;
     form.submit();
  }
  </code></pre>
  
  <p>File : editWorkSelector.jsp</p>
  
  <pre><code> 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");
  </code></pre>
  
  <p>Here lies the issue, due to mixed content the code flow is unable to reach workView.jsp.</p>
  
  <p>Error :</p>
  
  <pre><code>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
  </code></pre>
  
  <p>It will be very helpful to know how to fix this issue in my code.</p>