Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Session Invalidation Error  RSS feed

 
AnilPrakash Raju
Ranch Hand
Posts: 137
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I was testing if a person enters in a page without going through the login page.

Normally when a person logs out, I kill the session and send the person to the login page.

session.invalidate();
response.sendRedirect("login.jsp");

So if an user enters to a page other than the login page, i check for the userid session

if(session.getAttribute("userId")==null)
{
response.sendRedirect("login.jsp");
}

which should send the login page but i get the following error

HTTP Status 500 -

--------------------------------------------------------------------------------

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

java.lang.IllegalStateException
org.apache.catalina.connector.ResponseFacade.sendRedirect(ResponseFacade.java:423)
org.apache.jsp.clientdetails_jsp._jspService(org.apache.jsp.clientdetails_jsp:199)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:291)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


Any suggestions?

Thanks

Anil
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maybe no relation to the problem, but are you sure you want to pass a relative URL to sendRedirect ? You may consider using an absolute path like "/login.jsp".
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66142
141
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
An illegal state exception is usually an indication that you are trying to perform a forward or redirect after the response has been comitted.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From the API of sendRedirect:

IllegalStateException - If the response was committed or if a partial URL is given and cannot be converted into a valid URL
 
AnilPrakash Raju
Ranch Hand
Posts: 137
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Guys,

I got it workong on some pages. I have changed:
if(session.getAttribute("userId")==null)
{

<jsp:forward page ="index.jsp"/>

}

On some pages i can go into it after logout, but after refreshing it goes to the log in page.

I am not sure if it is due to caching

Anil
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!