Reputation: 3
I have the following code snippet in jsp:
String Key=null;
if(request.getParameter("project")!=null) {
Key = request.getParameter("project").trim();
}
if (AM == null) {
response.sendRedirect("../portal/login.jsp?from=index.jsp");
}
In here after redirection the variable Key is changed. How can I keep this variable unchanged after redirection?
Upvotes: 0
Views: 141
Reputation: 768
You can use key in session parameters otherwise you can use like this
String Key=null;
if(request.getParameter("project")!=null){
Key=request.getParameter("project").trim();
}
if (AM == null) {
response.sendRedirect("../portal/login.jsp?from=index.jsp&project="+Key);
}
Using key in session is better one.
Upvotes: 1
Reputation: 19327
You can't keep values in variables on every page redirection because WEB is stateless. so you need to use sessions
http://www.jsptut.com/sessions.jsp
Upvotes: 0