aspose file tools*
The moose likes Servlets and the fly likes RequestDispatcher error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "RequestDispatcher error" Watch "RequestDispatcher error" New topic
Author

RequestDispatcher error

Girish Vasmatkar
Ranch Hand

Joined: Apr 24, 2008
Posts: 201
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

Joined: Jan 28, 2008
Posts: 5575

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

Joined: Apr 28, 2008
Posts: 70
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

Joined: Dec 11, 2004
Posts: 13410

Originally posted by Girish Vasmatkar:

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


Please don't shout.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Girish Vasmatkar
Ranch Hand

Joined: Apr 24, 2008
Posts: 201
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

Joined: Jun 06, 2007
Posts: 2718
    
    6

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


SCJP, SCWCD.
|Asking Good Questions|
Girish Vasmatkar
Ranch Hand

Joined: Apr 24, 2008
Posts: 201
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

Joined: Apr 24, 2008
Posts: 201
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

Joined: Nov 29, 2005
Posts: 23
Error StackTrace will be more helpful to resolve this issue...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: RequestDispatcher error