This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
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: 199
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: 199
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: 2716
    
    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: 199
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: 199
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...
 
 
subject: RequestDispatcher error
 
Similar Threads
Values in Struts JSP page
JavaBean between Servlet and JSP
Session Advice
Passing Params
RequestDispatcher error(again)