Title: Servlet regains control after execution of .Forward()

Hi,

(Orion 1.3.8, Windows NT 4, JDK1.3)
This should not be possible, but it is happening. After executing the forward() method, control IS returning to the forwarding servlet. I have checked the archives and found that this has been an issue in previous versions of orion.

Here is the offending fragment:
---------------------------------------------------
if (condition XXX)
{
  request.getSession().setAttribute("username",username);
  request.getSession().setAttribute("password",password);
  System.out.println("[GATEWAYSERVLET]User has now logged in and is being redirected to reception");
  request.getSession().setAttribute("LoginFailure","false");
  getServletContext().getRequestDispatcher("/index.jsp").forward(request, response);
}
else
{
  System.out.println("[GATEWAYSERVLET]Authentication failure. Username:[" + username + "] Password:[" + password + "]");

  request.getSession().setAttribute("LoginFailure","true");
  getServletContext().getRequestDispatcher("/login.jsp").forward(request, response);
}
System.out.println("BUGGER ME! I AM HERE AFTER ALL");
----------------------------------------------------------------

Here is the output
----------------------------------------------------------------
[GATEWAYSERVLET]User has now logged in and is being redirected to reception
[INDEX.JSP]Session is established. UserId = gdoran. Printing frames with menus etc.
BUGGER ME! I AM HERE AFTER ALL
----------------------------------------------------------------

How can this be? Execution of the servlet(thread) is supposed to cease immediately and control handed to the target.

Am I missing something?

While I'm at it, does anyone know where I can obtain a good pattern example of JSP/Servlet based authentication, with a login page for any unauthenticated requests. I am pushing all requests through a single controller servlet and checking their session object for the required attributes, but I seem to be having problems with retrieving the session. Sometimes the attributes are there, sometimes they aren't.

Any guidance would be greatly appreciated.

Grant Doran
Principle Architect
iLaunch inc.
(02) 89257055
[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>


 


Reply via email to