• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Unavailable session in Controller Servlet.....

 
Ranch Hand
Posts: 170
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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’m tired of walking, and will rest for a minute and grow some wheels. This is the promise of this tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic