I have a URL (https://domainname/servlet/Test.jsp?param1=123¶m2=456), in my jsp page I retrieve the value of param1 and param2 using
request.getParameter("param1");
I perform a validation that if param1 and param2 is not null then I call a servlet. The problem that I am facing is the Servlet is called correctly in Google chrome browser, but meanwhile the servlet is not getting called correctly in Mozilla Firefox latest version (version 86.0.1) since the values of param1 and param2 is null when I get parameter values using request.getParameter("param1"). Please note I have added cache control headers in my jsp page and I dont want caching to occur in any browser. If I disable the caching config in the Firefox about:config the servlet is getting called in Firefox browser as well and my functionality is working as expected. Below is my source code for reference.
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%
request.setCharacterEncoding("UTF-8");
response.setContentType("text/html;charset=UTF-8");
response.setHeader("Cache-Control", "no-store, no-store, must-revalidate"); //HTTP 1.1
response.setHeader("Pragma", "no-cache"); //HTTP 1.0
response.setDateHeader("Expires", 0); //prevents caching at the proxy server
%>
<html>
<head>
<meta HTTP-EQUIV="content-type" CONTENT="text/html;charset=utf-8">
<META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE">
<META HTTP-EQUIV="Expires" CONTENT="-1">
<%
try {
param1 = request.getParameter("param1");
param2 = request.getParameter("param2");
if (param1 != null && param2 != null) {
System.out.println("Calling servlet");
response.sendRedirect(request.getContextPath() + "/servlet");
} else {
System.out.println("Not Going to call servlet");
}
} catch (Exception e) {
writeLog.error("Exception in view doc" + e);
}
%>
Aucun commentaire:
Enregistrer un commentaire