Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with RequestProcessor

Status
Not open for further replies.

pajarokillo

Programmer
May 3, 2004
30
ES
Why the code of the next processPreprocess method produce a IllegalStateException when it execute the method doForward?

protected boolean processPreprocess(HttpServletRequest request,HttpServletResponse response){
HttpSession session = null;
UserContainer user = null;

super.processPreprocess(request,response);

//Session Control if (!(request.getServletPath().equals("/login.do")))
session = request.getSession(false);
try{
if (session != null){
user = (UserContainer) session.getAttribute(IConstants.USER_CONTAINER_KEY);
if (user == null){
try{
doForward((moduleConfig.findForwardConfig("sessionExpired")).getPath(),request,response);
}
catch(IOException ex){
log.error("ERRORRRRRRRRRRRRRRRRRRRRRRRRRRRRRR: " + ex.getMessage());
}
catch(ServletException ex){
log.error("ERRORRRRRRRRRRRRRRRRRRRRRRRRRRRRRR: " + ex.getMessage());
}
}
}
}
finally{
session = null;
user = null;
}

return true;
}

Thus, in the struts-config.xml i have mapped like this

<global-forwards>
<forward name="sessionExpired" path="/sessionExpirada.jsp" />
</global-forwards>
 
After you forward to a JSP page, you don't want to process the action any more, otherwise it will get into a IllegalState, i.e. the request already handed off to a JSP, but the ActionServlet still trying to process it. You need to stop the ActionServlet to process the request further after you have forward to a different page. i.e.

Code:
.....
try{
  doForward((moduleConfig.findForwardConfig("sessionExpired")).getPath(),request,response);
  [COLOR=red]return false;[/color]
}
.....
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top