File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSP and the fly likes response.sendRedirect Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "response.sendRedirect" Watch "response.sendRedirect" New topic


bharani rao
Ranch Hand

Joined: Apr 06, 2009
Posts: 164

i'm running a html page which collects students' details( a.html).
when i submit it , it it should process the total average in b.jsp.

i was able to do that.
but the b.jsp should redirect the page to c.jsp where it should print the result.

i was able to redirect to c.jsp.

i used response.sendRedirect("c.jsp");

now it is showing error in the c.jsp.

this is c.jsp file.

the error is

this is b.jsp

where am i missing...
please help.

thanks in advance
Ankit Garg

Joined: Aug 03, 2008
Posts: 9462

Buddy you are using a very bad programming style. First of all, you said that your b.jsp is doing total/average but I don't see anything like that there. Secondly, If you redirect the user from b.jsp to c.jsp, then the values of variables in b.jsp will not be preserved. And doing business logic in JSPs is not a good practice. You should use a servlet instead of b.jsp. That servlet will calculate the total and average and then forward the request using RequestDispatcher to c.jsp. That servlet will also store the total and average as request attributes for c.jsp to retrieve and display. Please try to do this and ask any confusions...

SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63844

Perhaps this article can help you learn how to properly structure modern web applications.

[Asking smart questions] [About Bear] [Books by Bear]
bharani rao
Ranch Hand

Joined: Apr 06, 2009
Posts: 164
thank you Ankit and Bear
I agree. Here's the link:
subject: response.sendRedirect
jQuery in Action, 3rd edition