Two Submit Buttons

[b][red]This message was edited by stricks at 2005-6-1 13:40:40[/red][/b][hr]
Hello,

I have to "submit" buttons on my servlet:
----------------------------------------------------------

out.println("  ");

out.println("");

----------------------------------------------------------

They send me to a JSP page that looks like this:

------------------------------------------------------------
<%
//////////////////////////////////////////////////////
// All of this just increases/decreases //
// the page count so that it //
// knows to go to the next question. //
//////////////////////////////////////////////////////

String pageCounter = (String) session.getAttribute("pagecount");
int pageCount = Integer.parseInt(pageCounter);

String Add_Sub = request.getParameter("move");
String Add_Sub1 = request.getParameter("prev");

pageCounter = String.valueOf(pageCount);
session.setAttribute("pagecount", pageCounter);

%>



------------------------------------------------------------------

Now what I need to do is increase (if they click the Next Button) or decrease (if they hit the Previous button) the pageCounter by 1 (--/++).

Any suggestions?

Thanks,

Brian


Comments

  • Try using a session variable in jsp. Look at this page http://www.jsptut.com/Sessions.jsp for some information.

    Hope this helps you out.

    --=][tReShR][=--

  • : [b][red]This message was edited by stricks at 2005-6-1 13:40:40[/red][/b][hr]
    : Hello,
    :
    : I have to "submit" buttons on my servlet:
    : ----------------------------------------------------------
    :
    : out.println("  ");
    :
    : out.println("");
    :
    : ----------------------------------------------------------
    :
    : They send me to a JSP page that looks like this:
    :
    : ------------------------------------------------------------
    : <%
    : //////////////////////////////////////////////////////
    : // All of this just increases/decreases //
    : // the page count so that it //
    : // knows to go to the next question. //
    : //////////////////////////////////////////////////////
    :
    : String pageCounter = (String) session.getAttribute("pagecount");
    : int pageCount = Integer.parseInt(pageCounter);
    :
    : String Add_Sub = request.getParameter("move");
    : String Add_Sub1 = request.getParameter("prev");
    :
    : pageCounter = String.valueOf(pageCount);
    : session.setAttribute("pagecount", pageCounter);
    :
    : %>
    :
    :
    :
    : ------------------------------------------------------------------
    :
    : Now what I need to do is increase (if they click the Next Button) or decrease (if they hit the Previous button) the pageCounter by 1 (--/++).
    :
    : Any suggestions?
    :
    : Thanks,
    :
    : Brian
    :
    :
    :

    name them both (submit buttons) name="move"

    in the jsp page

    [code]
    String resp=request.getParameter("move")?request.getParameter("move"):"";
    if ("Next".equals(resp)){
    pageCount++;
    }
    else if("Previous".equals(resp)){
    pageCount--;
    }

    [code]
  • Thanks guys. That helped some.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories