Hello,

It might be a good idea to save the current value of the variable
into a URL parameter and access it with:
<%= request.getParameter("param_name") %>
if this returns null, then the visit is the first one and the value should
be translated to 1.
Functionality for buttons is just a normal POST form with a hidden field
or a link with request parameters.

If you want to use HttpSession class for saving the state of the number,
you must save the value to session as a java.lang.Integer, because you
can't save primitive type variables directly to session.

For example:
session.setAttribute("foobar", new Integer(5);

You also must convert the request parameter from String to int by:
String foo = request.getParameter("foo");
int i = 0;
try {
    i = Integer.parseInt(foo);
} catch (NumberFormatException e) {}

HTH,
Kare

On Thu, 22 Mar 2001, S. Jyotinarayan wrote:

> I have a jsp page with 'increase' and 'decrease' buttons and a variable. I
> want the variable to be initalised to 1 when this jsp page is first opened.
> And the variable should increase and decrease as I press on the respective
> buttons and be displayed on the same page. How could I do this.
> Thanx a lot in advance.
> JNS
>
> ===========================================================================
> To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
> For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
> Some relevant FAQs on JSP/Servlets can be found at:
>
>  http://java.sun.com/products/jsp/faq.html
>  http://www.esperanto.org.nz/jsp/jspfaq.html
>  http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
>  http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
>

--
Kare Nuorteva
http://www.kare.uklinux.net/

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

Reply via email to