How to transfer the value of a session attribute to another application that resides on the same web server. The reason I should know this is because we have a project that is shared by the module. Each module is redirected to another, which passes the value through the session. This session will be used to determine which user is accessing this module.
Suppose I have a LogIn module that is separate from my other module.
Here is my sample code:
Url example http: // localhost: 8080 / Login
authorization.jsp: this page will call after userId is entered by the user, and then send
page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"
HttpSession sessionid = request.getSession();
String userId = request.getParameter("userId");
sessionid.setAttribute("userId", userId);
System.out.println("SESSION IS :" + sessionid.getAttribute("userId"));
response.sendRedirect("http://localhost:8080/OtherModule");
Url example http: // localhost: 8080 / OtherModule
, userId
protected void doGet(HttpServletRequest request, HttpServletResponse response){
HttpSession session = request.getSession();
if(session.getAttribute("userId") != null){
System.out.println("SESSION ID @ GET: " + session.getAttribute("userId"));
} else {
System.out.println("No Session for userId");
}
}
, , . , .