This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes Servlets and the fly likes writing JSP page Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Servlets
Bookmark "writing JSP page" Watch "writing JSP page" New topic
Author

writing JSP page

Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
could anybody tell me how to write a JSP page that has
NEXT and PREV buttons, and "ACTION" should go to one servlet.
How to get the NEXT or PREV value in the servlet
thank u
Pragya Prakash
Ranch Hand

Joined: Sep 18, 2000
Posts: 42
Hi Kavin,
The first page may be a plain html page.
And u can set the action attribute to point to a servlet.
To get the values of next/prev use this in the service method of the servlet:-
//note thar next & previous both are of type submit
//this way, u will either next or previous at any given time.
String next=req.getParameter("next")
String prev=req.getParameter("previous")
if(next.equals("next")) {
//code
}
if(Previous.equals("previous")) {
//code
}
here is the HTML code, one could use:-
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
</HEAD>
<BODY>
<form method=post action="/MyServlet">
<STRONG>GUI goes here....... </STRONG>
<P> </P>
<INPUT type="submit" value="Next" id=button1 name=next>
<INPUT type="submit" value="Previous" id=button2 name=previous>
</form>
</BODY>
</HTML>
Hope that helps. Let me know, if u r having any further queries
Originally posted by kavin:
could anybody tell me how to write a JSP page that has
NEXT and PREV buttons, and "ACTION" should go to one servlet.
How to get the NEXT or PREV value in the servlet
thank u

Paul Ramsden
Greenhorn

Joined: Sep 22, 2000
Posts: 28
Just a note if you are thinking of using graphic buttons:
Assume the button has the name 'NEXT'. When you query the presence of the button in your servlet you should do the following:
if (req.getParameter("NEXT") != null | | req.getParameter("NEXT.x") != null)
{// NEXT button was clicked
}
(I leave the old form in the servlet in case the designer chooses to go back to normal buttons)
 
 
subject: writing JSP page