I am trying to pass two values from my JSP page to servlet using request dispatcher.
Here is the JSP code:
<%
String companyName = (String) request
.getAttribute("adminCompnayName");
String tenantId = (String) request.getAttribute("adminTenantId");
request.setAttribute("adminCompnayName", companyName);
request.setAttribute("adminTenantId", tenantId);
request.setAttribute("adminTenantid","my compnay");
request.setAttribute("adminCompanyname"," my tenant id");
String servletName="../StoreUserDetails";
RequestDispatcher dispatcher = request.getRequestDispatcher(servletName);
if (dispatcher != null){
dispatcher.forward(request, response);
}
These two values are received from another servlet.
Here is the servlet code where I am receiving values.
String tenantId = (String) request.getAttribute("adminTenantid");
String companyName = (String) request
.getAttribute("adminCompanyname");
out.println("--------------------------"
+ request.getAttribute("adminTenantid"));
out.println("--------------------------"
+ request.getAttribute("adminCompanyname"));
But I am getting null values.
--------------------------null
--------------------------null
How to fix it?