File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes URGENT!!!! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Servlets
Bookmark "URGENT!!!!" Watch "URGENT!!!!" New topic
Author

URGENT!!!!

Hrithik Roshan
Greenhorn

Joined: Dec 12, 2001
Posts: 23
hi, i m developing an application using MVC pattern.
there is one jsp page in which i have next and previous buttons;
my problem is when i hit next button;
i can see my jsp on the address bar!
instead of my servlet(which is must);
can someone tell me wht to pass to the servlet
in order to do the paging!
put wht things into session???
thanx in advance!
Zakaria Haque
Ranch Hand

Joined: Jan 02, 2002
Posts: 60
most likely nothing to do with sessions. Check for the following
is you next button linking to the jsp page rather than the controller ?
are you using Http redirection (typically with the sevdRidect() method) rather than RequestDispatcher while processing the next request?


tobe bondhu nouka bherao<br />shonabo gaan aj shara raat
Hrithik Roshan
Greenhorn

Joined: Dec 12, 2001
Posts: 23
i m linking my jsp to the controller servlet
and i m using requestDispatcher
thanx for the reply
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

use forward() instead of sendRedirect()
Hrithik Roshan
Greenhorn

Joined: Dec 12, 2001
Posts: 23
well..
i think i have to repeat my question
i knw wht to use to forward my servlet!
my question is
how to pass the request from jsp back to the controller servlet when i m paging;
wht things to put in session??

that is (next and previous)
wht things to put in session??
can someone send me "someCode"
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

When you click the 'next' button, you see your jsp page in the address bar.

So I'm thinking of ways to produce that result. One way is that you are using links, and your 'next' link is coded as:
<a href="somepage.jsp">Next</a>

That somepage.jsp appears in the address bar should be no surprise, so I'll assume your link is not coded that way.

You are probably using a FORM button. So this button is a submit to your servlet. We are now in your servlet, and also, we know what page is 'next'... How do you use the requestDispatcher() in such a way that your 'next' page appears in the browser's address bar? Answer: use sendRedirect() instead of forward(). Which is why I said use forward() instead.

So is your problem in how to get the servlet to understand what is 'next'??

One way to do this, is to have two hidden fields in the FORM. One called 'previous', one called 'next'. The servlet will use the name of the submit button (you can have more than one submit button for a form, each named differently), plus the hidden fields, to determine what is 'previous' and 'next'.

Nothing need be placed in the session.

p.s. - Asking for 'the code' is a sure way for people NOT to send you 'the code'.
Hrithik Roshan
Greenhorn

Joined: Dec 12, 2001
Posts: 23
Originally posted by Mike Curwen:
When you click the 'next' button, you see your jsp page in the address bar.

So I'm thinking of ways to produce that result. One way is that you are using links, and your 'next' link is coded as:
<a href="somepage.jsp">Next</a>

That somepage.jsp appears in the address bar should be no surprise, so I'll assume your link is not coded that way.

You are probably using a FORM button. So this button is a submit to your servlet. We are now in your servlet, and also, we know what page is 'next'... How do you use the requestDispatcher() in such a way that your 'next' page appears in the browser's address bar? Answer: use sendRedirect() instead of forward(). Which is why I said use forward() instead.

So is your problem in how to get the servlet to understand what is 'next'??

One way to do this, is to have two hidden fields in the FORM. One called 'previous', one called 'next'. The servlet will use the name of the submit button (you can have more than one submit button for a form, each named differently), plus the hidden fields, to determine what is 'previous' and 'next'.

Nothing need be placed in the session.

p.s. - Asking for 'the code' is a sure way for people NOT to send you 'the code'.

hi, Mike
whoa
(p.s. - Asking for 'the code' is a sure way for people NOT to send you 'the code'.)
well
i send code if i can do it!
i expect the same in RETURN!
nothin NEW!!!
 
GeeCON Prague 2014
 
subject: URGENT!!!!