• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

RequestDispatcher error

 
Girish Vasmatkar
Ranch Hand
Posts: 201
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ranchers,
i am using a servlet to check for user's login information and if everything goes right i am creating a bean named userBean and setting its properties and then putting that userBean into session scope and then forwarding the request to another jsp which will display the user's profile similar to what Orkut does.here is code sample
Assume i have set userBean and then i am writing this code


HttpSession session=request.getSession();
session.setAttribute("userBean",userBean);
rd=request.getRequestDispatcher("/profile.jsp");
rd.forward(request,response);
rd.forward(request,response);


WHAT'S WRONG WITH THIS CODE PLEASE HELP ME...THANK YOU
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Girish Vasmatkar:




rd=request.getRequestDispatcher("/profile.jsp");
rd.forward(request,response);
rd.forward(request,response);


[/QB]



why you try to forward 2 times!!!
 
Rodrigo Tomita
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, Girish,

Can you tell us exactly what is the error you are getting? (or were you really just forwarding it twice?)
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Girish Vasmatkar:

WHAT'S WRONG WITH THIS CODE PLEASE HELP ME...THANK YOU


Please don't shout.
 
Girish Vasmatkar
Ranch Hand
Posts: 201
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sorry ,i am not trying to forward it 2 times ,it's my mistake i am only forwarding 1 time and the exception i am gettin is --attemted bean operation on null object.
 
Amit Ghorpade
Bartender
Posts: 2854
10
Fedora Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you getting the exception in the servlet or in th forwarded JSP?
Have you instantiated the bean properly?
I dont see any bean instantiation code above.



Hope this helps
 
Girish Vasmatkar
Ranch Hand
Posts: 201
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My dear friend i have done bean instantiation like

UserBean userBean=new UserBean();

the error message i am getting at tomcat window is

"Attempted bean operation on null object"
Thanks
 
Girish Vasmatkar
Ranch Hand
Posts: 201
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I could have posted the whole code but i am not allowed to post it because when i am posting the code the forum is not allowing my code to be posted.
 
Laxmikant Ruikar
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Error StackTrace will be more helpful to resolve this issue...
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic