This week's giveaways are in the MongoDB and Jobs Discussion forums.
We're giving away four copies of Mongo DB Applied Patterns and 4 resume reviews from Five Year Itch and have the authors/reps on-line!
See this thread and this one for details.
The moose likes Servlets and the fly likes Unavailable session in Controller Servlet..... Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of Mongo DB Applied Patterns this week in the MongoDB forum
or a resume review from Five Year Itch in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Servlets
Reply Bookmark "Unavailable session in Controller Servlet....." Watch "Unavailable session in Controller Servlet....." New topic
Author

Unavailable session in Controller Servlet.....

Gabriel Fox
Ranch Hand

Joined: Oct 17, 2001
Posts: 170

Hi Pals,I am doing the following in my controller servlet(using a front controller design pattern):
1.After front end validation for username and password,i then do
my Authentication in my Controller servlet by checking the database for the name and password entered.
If valid user,then i get the session object from the request as follows:
class controllerServlet extends HttpServlet
{
HttpSession session;
BigBean oneBean;
Hashtable refHash;



public void doPost(---------)
{
if(Ok button is pressed on LogOn screen do authentication)
{
if( user is valid after checking)
{
session=request.getSession(true);
session.setAttribute(name,objBean);
}
}
// the problem is after checking that session is NOT null
below ,i still found out that it is null in the second
inner-if block(i.e.if(refHash==null)).And i had to get my session again to set the refHash in a session scope.
if(session!=null)
{
//this block is executed after authentication and after seeing homepage
if(oneBean==null)
{
oneBean = new BigBean();

session.setAttribute("schemer",oneBean);
}
if(refHash==null)
{
//i had to do :session=request.getSession(true);
refHash = new Hashtable( );
session.setAttribute("addressHash",refHash);
}
}

}
}
Please help,checking that session is NOT null before executing a block which binds some objects to session using session.setAttribute(name,obj).And finding session to be null in the block later.Cheers.
 
I agree. Here's the link: http://zeroturnaround.com/jrebel/download
 
subject: Unavailable session in Controller Servlet.....
 
Similar Threads
What is the equivalent to scriptlets for invalidating the session in jsp
How to avoid Session Collision between Jsp And Servlets
session keeps timing out
session handling
Session Creation?