You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by mthalis <di...@yahoo.com> on 2009/02/17 11:26:57 UTC
session management
i have already implemented login, logout parts using struts(jsp). But the
case is after logged out, when i press back button it is redirected to the
particular page that i was in before logged out. these are my codings, and
plz kind enough to give me reasonable answer.
//set sessions//
HttpSession session=request.getSession();
session.setAttribute("userName", userLoginForm.getName());
//verify log or not
<%
String userId=(String)session.getAttribute("userName");
if(userId != null){
%>
///if not log
<%
}
else{
response.sendRedirect("./index.jsp");
}
%>
//logout
<%
session.removeAttribute("userName");
session.invalidate();
response.sendRedirect("./welcome.jsp");
%>
--
View this message in context: http://www.nabble.com/session-management-tp22054409p22054409.html
Sent from the Struts - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: session management
Posted by Paweł Wielgus <po...@gmail.com>.
Hi mthalis,
maybe this will help:
http://poulwiel.blogspot.com/2009/01/browser-back-button-and-caching-problem.html
but to be honest i don't know if i understand Your problem at all.
Best greetings,
Paweł Wielgus.
2009/2/17 mthalis <di...@yahoo.com>:
>
> i have already implemented login, logout parts using struts(jsp). But the
> case is after logged out, when i press back button it is redirected to the
> particular page that i was in before logged out. these are my codings, and
> plz kind enough to give me reasonable answer.
>
> //set sessions//
> HttpSession session=request.getSession();
> session.setAttribute("userName", userLoginForm.getName());
>
> //verify log or notMaybe
> <%
> String userId=(String)session.getAttribute("userName");
> if(userId != null){
> %>
>
>
> ///if not log
> <%
> }
> else{
> response.sendRedirect("./index.jsp");
> }
> %>
>
> //logout
> <%
> session.removeAttribute("userName");
> session.invalidate();
> response.sendRedirect("./welcome.jsp");
> %>
>
> --
> View this message in context: http://www.nabble.com/session-management-tp22054409p22054409.html
> Sent from the Struts - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: session management
Posted by Paweł Wielgus <po...@gmail.com>.
Hi,
i wasn't able to understand Your problem,
so i was thinking that the code You cited below was about the problem
discussed on my blog.
If it's not this problem than try to describe the problem in other words,
i simply don't get it.
Best greetings,
Paweł Wielgus.
2009/2/20 mthalis <di...@yahoo.com>:
>
> Give me another suggestion pz.
>
>
> mthalis wrote:
>>
>> i have already implemented login, logout parts using struts(jsp). But the
>> case is after logged out, when i press back button it is redirected to
>> the particular page that i was in before logged out. these are my codings,
>> and plz kind enough to give me reasonable answer.
>>
>> //set sessions//
>> HttpSession session=request.getSession();
>> session.setAttribute("userName", userLoginForm.getName());
>>
>> //verify log or not
>> <%
>> String userId=(String)session.getAttribute("userName");
>> if(userId != null){
>> %>
>>
>>
>> ///if not log
>> <%
>> }
>> else{
>> response.sendRedirect("./index.jsp");
>> }
>> %>
>>
>> //logout
>> <%
>> session.removeAttribute("userName");
>> session.invalidate();
>> response.sendRedirect("./welcome.jsp");
>> %>
>>
>>
>
> --
> View this message in context: http://www.nabble.com/session-management-tp22054409p22114881.html
> Sent from the Struts - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: session management
Posted by mthalis <di...@yahoo.com>.
Give me another suggestion pz.
mthalis wrote:
>
> i have already implemented login, logout parts using struts(jsp). But the
> case is after logged out, when i press back button it is redirected to
> the particular page that i was in before logged out. these are my codings,
> and plz kind enough to give me reasonable answer.
>
> //set sessions//
> HttpSession session=request.getSession();
> session.setAttribute("userName", userLoginForm.getName());
>
> //verify log or not
> <%
> String userId=(String)session.getAttribute("userName");
> if(userId != null){
> %>
>
>
> ///if not log
> <%
> }
> else{
> response.sendRedirect("./index.jsp");
> }
> %>
>
> //logout
> <%
> session.removeAttribute("userName");
> session.invalidate();
> response.sendRedirect("./welcome.jsp");
> %>
>
>
--
View this message in context: http://www.nabble.com/session-management-tp22054409p22114881.html
Sent from the Struts - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: session management
Posted by Dave Newton <ne...@yahoo.com>.
mthalis wrote:
> i have already implemented login, logout parts using struts(jsp). But the
> case is after logged out, when i press back button it is redirected to the
> particular page that i was in before logged out. these are my codings, and
> plz kind enough to give me reasonable answer.
>
> //set sessions//
> HttpSession session=request.getSession();
> session.setAttribute("userName", userLoginForm.getName());
>
> //verify log or not
> <%
> String userId=(String)session.getAttribute("userName");
> if(userId != null){
> %>
>
>
> ///if not log
> <%
> }
> else{
> response.sendRedirect("./index.jsp");
> }
> %>
>
> //logout
> <%
> session.removeAttribute("userName");
> session.invalidate();
> response.sendRedirect("./welcome.jsp");
> %>
>
Leaving the discussion about the scriptlets aside, and that this isn't
really a Struts issue...
When the user hits the "back" button if a page has been cached it will
be displayed--no server interaction, so no server interaction. Turn off
page caching--this forces the browser to go back to the server,
whereupon it will discover the user is no longer logged in, and run
the... scriptlet.
Dave
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org