This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

URGENT!!!!

 
Hrithik Roshan
Greenhorn
Posts: 23
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 60
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Hrithik Roshan
Greenhorn
Posts: 23
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i m linking my jsp to the controller servlet
and i m using requestDispatcher
thanx for the reply
 
Mike Curwen
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
use forward() instead of sendRedirect()
 
Hrithik Roshan
Greenhorn
Posts: 23
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3695
IntelliJ IDE Java Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 23
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!!!
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic