Updating value of a variable on a JSP page

Hya!
I am very new to JSP and I am struggling to make a homepage work according to the specifications my group has decided to use. I would be grateful if you could help me in this, as it's really urgent. Let me describe the issue:
My web site contains a set of six JavaBeans that keep information that is more a less unchangeable (it works as a table). The information that is kept by the JavaBeans can be viewed by the user once he/she makes a selection. This information then will help the user in deciding to buy a certain number of tickets. That's the point where the problem appears.
I need the variable 'totalTickets' to vary depending on each user's purchase. I've set the original value to 100 on JavaScript but that means that in each visit this number would be reset to 100 again, as JavaScript is a client-side technology. On the other hand if I set this variable in JSP the same problem would happen. Would there be a way to allow this variable to be reset after each visit? What would I need to make this possible?
I am looking forward to hearing from all of you.
Yours sincerely,
Saulo

Is this correct,
1. User login to the system for the first time. Then TotalTicket count will be set to 100.
2. User purchase a ticket and the count will become one less (i.e 99).
3. For every purchase of a ticket, count will be reduced by one.
4. User logs out. Now let us say, the count is 95. (i.e user has purchased 5 tickets).
5. Now again user login to the syatem. The ticket count must be initialized to 95.
and so on.
If this is what you want, then you must either store the TicketCount in the database or atleast in the application context.
int totalTicket=100;
Hashtable ticketCounterMap=(Hashtable)application.getAttribute("ticketCounterMap")
if(ticketCounterMap == null)
     ticketCounterMap = new Hashtable();
     ticketCounterMap.add("login_user_name",new Integer(totalTicket));
     application.setAttribute("ticketCounterMap");
else
     totalTicket = ((Integer)ticketCounterMap.get("login_user_name")).intValue();
and in case of purchasings.
if(purchase.....)
     totalTicket--;
     ticketCounterMap.add("login_user_name",new Integer(totalTicket));
     application.setAttribute("ticketCounterMap");
Hope this helps.
Sudha
P.S:- There may be errors in the above code. This is just to give you an idea.

Similar Messages

  • How to use value returned from a bean in jsp page

    Hi All,
    I have a string array value being returned from a javabean to a jsp page. I want to be able to assign the value to a variable in the jsp page.
    How do I do this?
    Many thanks :)

    thanks for your response.
    I actually used something like this:
    <% String loggedin = log.User(user,password);
    out.println(loggedin);
    %>i am not yet as much of an expert on beans as i would like to be, but i thought it is not really a bean if it has a getter method which takes arguments?

  • POST variables in a JSP page

    I have a JSP page which recieves a number of arguments.
    One of those arguments in a desination URL. The JSP page picks this up and then uses a response.sendRedirect(URL) call to forward the user to this page.
    Is there anyway of passing these other arguments across to this destination page as hidden variables.
    I dont want to append these variables to the existing URL as they should remain hidden.
    What other methods can I use for these variables to accompany the sendRedirect call or is there a different approach thats required for this case ??
    Thanks in advance,
    Richard

    You can try this. It works.
    out.println("<html>");
    out.println("<head>");
    out.println("<title></title>");
    out.println("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">");
    out.println("</head>");
    out.println("<body bgcolor=\"#FFFFFF\" text=\"#000000\" onLoad=\"javascript:document.forms[0].submit();\">");
    out.println("<form name=\"formulario\" method=\"post\" action=\"http://PutHereTheURLOfsendRedirect\">");
    // Put here your hidden variables.
    out.println("<input type=\"hidden\" name=\"hiddenField1\" value=\"hiddenvalue1\">");
    out.println("<input type=\"hidden\" name=\"hiddenField2\" value=\"hiddenvalue2\">");
    out.println("</form>");
    out.println("</body>");
    out.println("</html>");

  • Updations done in valueChangelistener not reflected in jsp page.

    I want to update most of my backing bean properties in a value change listener. But the changes made in valueChangeListener merthod are not reflected in my jsp page. Can anyone explain how to do this?
    Edited by: Ashok_431 on Aug 19, 2008 10:52 AM

    Ashok_431 wrote:
    What is significance of immediate attribute.It shifts conversion and validation to the 2nd JSF phase.
    Check this article for an explanation of the JSF lifecycle: [http://balusc.blogspot.com/2006/09/debug-jsf-lifecycle.html].
    Check this article for the use of the immediate attribute: [http://balusc.blogspot.com/2007/10/populate-child-menus.html].

  • Need help passing variables to another jsp page

    I am working in a shopping cart with multiple lines and I am wanting to pass 2 variables to another page which is accessed from a link.
    What I have so far is the following:
    This is on the shopping cart JSP page with the link
    <input type="hidden" name="shopCartReqDate1<%=i%>" id="shopCartReqDate1<%=i%>" value="<%= retVals[9] %>">
    <input type="hidden" name="shopCartExpDate1<%=i%>" id="shopCartExpDate1<%=i%>" value="<%= retVals[10] %>">
    Need it Earlier?
    I am wanting to pass it to the HAC_Help_Text_Need_it_Earlier.jsp page
    Right now on the HAC_Help_Text_Need_it_Earlier.jsp page I have the following code:
    String shopCartReqDate1 = IBEUtil.nonNull(request.getParameter("shopCartReqDate1"));
    String shopCartExpDate1 = IBEUtil.nonNull(request.getParameter("shopCartExpDate1"));
    Do I need to create a function and do a document.getElementById?
    Thanks for the help!

    As far as I understand your question You don't have to use document.getElementById. Just submit the form and then on the next page You'll just pull the variables out from the request object.

  • Retrieve values from a table of a JSP page in Servlet.

    Hello all,
    I am new in JSP servlet world, I want to create a grid on JSP page using Servlet.
    Suppose i have some records in a JSP page and This JSP page will display these records in a tabular form. And, on a button click that table data should be
    accessible in servlet,
    Now, How can i traverse among all the rows of that table of JSP page in servlet. or How can i retrieve a specific cell record of that table of JSP page in servlet.
    Can anyone please answer this.
    Thank you and regards.

    Hi,
    Create in your HTML form inputs with the same name i.e.:
    <input name="a[]" value="2" >
    <input name="a[]" value="9" >
    In your jsp page use :
    String Values[] = request.getParameterValues("a[]") ;
    This will give you a string array of two elements.
    for (int x = 0; x < Values.length; x++)
        System.out.println(Values[x]) ;
    }Will print :
    2
    9
    Hope this helps.
    Bill Moo

  • How to pass variables between 2 jsp pages-help

    Hi,
    I have a question like this.
    As an example consider I have 3 .jsp pages.
    page1.jsp - In this html form it has some textboxes to enter employee details.
    page2.jsp - In this page it has a "PRINT" button which allows the user to click.
    page3.jsp - A new popup window which having the same content as page2.jsp, but without the PRINT button.
    But my problem is this. In this page3.jsp,it should be display the entered textbox values as page2.jsp. But these values are not displaying here. They display as NULL.
    I use as follows, but it still not working.
    <%= request.getParameter("effDate")%>.
    Could you please tell me how to hold these values when I came from page2 to page3.
    I'm using JSP 1.2 with javaBeans.
    Thanks.

    Well,
    If you are popping up a new window, and you insisting on pulling the data out of the request's parameter map. Then you will need to add the values to the query string of your url.
    window.open("http:localhost/page3.jsp?itemOne=itemOneValue&itemTwo=ItemTwoValue, '', '');
    Alternative Option:
    When posting from page 1 to page two, store your information into session scope
    request.getSession().setAttribute("valeuOne", "valueOneValue");
    Then instead of pulling from the paramter map, use request.getSession().getAttribute("valueOne") in your third page.
    Hope that helps.
    Thanx
    Cardwell

  • How to change value of user variable with change in Page View Dropdown

    Hi All,
    I have a classic planning application, on one of my dataform i put members of Dim_A in Page view and on row view i filter members of Dim_B on the basis of User variable i.e row contains the @Childern(&My_User_Variable). I have following members in both Dimensions:
    Dim_A
    ___A_Mem1
    ___A_Mem2
    ___A_Mem3
    Dim_B
    ___B_Mem1
    ______B_Mem1_1
    ______B_Mem1_2
    ______B_Mem1_3
    ___B_Mem2
    ______B_Mem2_1
    ______B_Mem2_2
    ______B_Mem2_3
    ___B_Mem3
    ______B_Mem3_1
    ______B_Mem3_2
    ______B_Mem3_3
    Now is there any way through which the value of My_User_Variable changes automatically when user select a member of Dim_A in Page View drop down, so that when user press go button then my rows would also be re filtered according to new value of User Variable.
    Right now user first make change in User Variable then select its matching member from Dim_A and then rows are filtered, so i want my user to only make selection in Drop down and press go rest all would be done automatically.

    Hi,
    There was a little controversial post on a similar question:
    Re: Hyperion Planning Data Form
    I love controversy!
    Cheers,
    Alp

  • Checking Value passed by Checkbox in a jsp page ??

    hi all,
    in my jsp page, i've a checkbox on a page & after submitting that page to another one, i want to check whether the checkbox was clicked or not..since in my code i wanna something like this...
    if checkbox is clicked
    //task1
    else
    {//task2
    Can anyone please help me how to go 'bout it !

    Hi ! romit
    As the solns suggested above r correcti just wanna add another thing of ur interest ie when the checkbox is checked ,the url contains the thecked checkbox name equals "on"...i hope u understood what i meant...
    ie
    <input type=checkbox name="checkIt">
    now in url...it will be like....
    http://localhost/...../..... ..?...&check=on&.....
    in case the checkbox is checked...else null value is passed....

  • Get the  value and pass it to child jsp page

    Hi All,
    I want to get the attribute value from the adf table in my parent jsp page and again send it to the child jsp page.I'm very new to adf.Please any body give me a example for this.Please help me.
    Thanks in advance!

    Sorry......
    I'm using Jdeveloper 11.1.1.5 version.In my adf application i have two jsp pages.One is parent.jspx and another one is child.jspx.In my parent.jspx page i have adf table.Now i want to get the attribute value from adf table which is in parent.jspx page and i want to send that values to the child.jspx page.How can i do this.Please give me the example.
    Thanks!

  • Passing values at run time through a JSP page to selection formula to crystal report

    <p>hi,</p><p>   i am using one jsp page.in that page there is a field to select a date </p><p>this value will go to the report and report contain one selection formula.</p><p>which value we are passing on that basis the report should display</p><p>with date which we are passing  from GUI.</p><p>help.............................................................</p><p>//R</p>

    I believe the value of this is based on the owner of the scheduled object.  So if the Admin is scheduling it on behalf of a user I think it should use the user the Admin scheduled on behalf of.  It should be simple to test, simply create a report with this value being displayed and nothing else and see what values you get.

  • How to pass a java script variable to a JSP page

    How to assign a javascript variable value to a jsp variabe
    <script>
    var scroll="100"
    </script>
    <%
    String age=[ here i need to set the value of "scroll" ]
    %>
    is it possible ,
    thanks

    assign this scroll to a hidden field in a form
    and pass via form to server this may be one way or
    set attribute scroll and then access to server side
    may this help you
    --yogeshb                                                                                                                                                                                                                                                                                                                                                                           

  • How to use jstl variable in a jsp page

    Hi all,
    I am new to JSTL and i want to access the value of jstl in jsp.
    when i use the tag like below it is displaying the value ""
    <c:out value="${ack}"/>
    But as ack is string, i want to convert it into int. and i have written like
    <c:set var="ackvalue" value="${ack}"/>
    and int ack = Integer.parseInt(ackvalue);
    But it is showing error like varialbe can not be resolved: ackvalue
    can anybody please help me regarding this?
    Waiting for your warm response.
    Thanks in advance

    Hi,
    Thanks for your immediate reply.
    I am able to display the ackvalue when i am using
    <c:set var="ackvalue" value="${ack}"/>
    and <c:out value="${ackvalue}"/>
    But my actual requirement is to use the ack value in
    switch statement. if i can assign the value to a
    String variable, then it si easy for me to proceed.
    Please help me in this regard.
    Thanks,You can use the c:choose, c:when and c:otherwise tags
    <c:choose>
        <c:when test = "${ackvalue == 1}">
               //do stuff
        </c:when>
        <c:when test = "${ackvalue == 2}">
               //do some other stuff
        </c:when>   
       <c:otherwise>
              //stuff
        </c:otherwise>
    </c:choose>ram.

  • How to get value from a checkbox in a jsp page?

    hi there
    i have a form in a jsp which contains a <input type='checkbox' name='xx'>
    when i submit the form, how can i get the value for this checkbox? i could use request object to get parameter. i tried the following and could not get any value:
    request.getParameter("xx");
    is there any to get it? thanks.

    "checkbox" can have multiple values b/c you can check more than 1 checkbox and they can have same name.
    Example
    <input type="checkbox" name="number" value="1">one
    <input type="checkbox" name="number" value="2">two
    <input type="checkbox" name="number" value="3">three
    To get values of "number" field:
    String [] numberValues = request.getParameterValues("number");
    where numberValues[0] is the 1st value checked, numberValues[1] is 2nd value checkted and so on.....
    If you have no checkbox checked then you might get a "null pointer exception", so make sure you check to see if it's null first before accessing your numberValues array.
    If you just have 1 checkbox; then you can just call request.getParameterValue("number") and that will return your value.

  • Same variable on every JSP page

    Hi All,
    I'm just a beginner with JSP so excuse me if this is a 'stupid' question.
    I'm building an Application that uses MySQL database everything works ok, but
    I would like to know if there is a way to have a variable that I can use on every page.
    The reason is, is because I have lots of pages (and growing) where I have the
    database connect string with username password, but due to security reason
    the user/pass for the database will change every now and then.
    I'm familiar with Coldfusion and in Coldfusion you can setup an Application.cfm file. This file is called before every other .cfm file. Is there something like that
    in JSP?
    The solution I thought of is, putting the connect string into a session variable.
    Is this a could idea?
    If not, are there any other better ways of achiving this?
    Thanks for any help!
    Steven.

    Are you using Tomcat?
    Because Tomcat supports things like Application.cfm did with CF. They go in web.xml, I believe (I don't use tomcat myself).
    Your database connect (and interaction) should not be handled by individual pages. It should be in a bean, connection pooling (tomcat), JSTL, or other more scalable method (or combination of techniques that works for you). If you put it all in scriptlets, you really limit yourself later.
    I am assuming from your post that the username/pass is the same for all users. If it isn't, use a session-scoped bean to hold that info.

Maybe you are looking for

  • Passing 900 character value into a Single line

    Hi Experts, I have a scenario that i have to pass 900 character value to a single field. After that i need to download this internal table into an text file. What happening after some characters the values are not getting passed into my varaibale. So

  • SAPGUI and Portal Authentication using AD Credentials with usr/passw prompt

    Hi Experts, We have the following requirements: 1. Portal/EP has UME set to ABAP (in other words using ECC6 system's user/password). 2. ECC6 user-id's differ from Active Directory user. 3. User logs in to Active Directory. 4. User wants to log on to

  • Any info on Flash 64.bit ?

    Is there any word on Flash for 64-bit Internet Exployer ? Is there any other software ?

  • Help with restoring from Time Machine Backup from another computer

    I was required to dump my Mac OSX on my MacBook Pro and convert to a windows machine to use a testing software that did not allow boot camp.  Before doing so, I backed up my hard drive to a partition of my iMac via a wireless connection.  I am now us

  • I want to restore my new macbook pro to factory settings

    I just bought a new 13 inch Macbook pro mid 2012 it shipped with Lion so I updated to Mountain Lion but like two weeks later it started to run slow, I want to restore my Mac to factory settings. I have been searching how to do it but everyone say tha