Forums Register Login

How to keep values from calling multiple jsp

+Pie Number of slices to send: Send
Hello,

I have a question. I have one jsp (a.jsp) calling (b.jsp). Once a calls b it passes most of the information. Once I have b and all the values are filled out and I want to call c.jsp how do I keep the values from a in b and be able to insert c values.

One issue is that a value in b.jsp name is being set from a variable from a.jsp. When I call c.jsp and I pass a value back how do I set b.jsp name value from what I passed from c.jsp and not have the one from a.jsp.

Thank you,
Randy
+Pie Number of slices to send: Send
You'll need to be a bit more precise in your terminology.

JSPs don't "call" each other. The can include each other, redirect to each other, forward to each other, or submit to each other. Which of these do you mean by "call"?

Also, what is "pass data"? Scoped variables on the session? Request parameters from a query string or form elements?
+Pie Number of slices to send: Send
All items being sent from jsp to jsp are scoped.

Form b submits to form c. When it is submitted it transfers a value from b to c. From the info i get from b i set up a list of options with radio buttons in c. Once the option is selected and they select the finished button it sumbits back to b and with it goes a different value that I need to set.

From a to b I am not sure. All I know is that it sets all the variables once it is called. It will not go back to a though.

Should i be using the redirect or forward instead of submitting?


Thank you,
Randy
+Pie Number of slices to send: Send
Use a servlet as your controller and submit all of your (forms/jsp's) to this servlet. That way when the request transfers from a.jsp it is forwared to the servlet where you can get the values using request.getParameter() and so on for b.jsp and c.jsp etc.

Its a good idea to have some sort of contoller when you are using multiple jsp pages and forwarding requests between them.
+Pie Number of slices to send: Send
 

Originally posted by Randy Tatham:
All items being sent from jsp to jsp are scoped.



Where? Session? Request?


Form b submits to form c

.

I assume you mean to page c which contains a form?


When it is submitted it transfers a value from b to c.



How?

Once the option is selected and they select the finished button it sumbits back to b and with it goes a different value that I need to set.



Don't know what you mean by the part that I put in bold.

Should i be using the redirect or forward instead of submitting?



Probably not. Redirects and forwards are only used for immediate transfer from one resource to another.
+Pie Number of slices to send: Send
Ok here is what I think i am goign to do. I am going to pass the other 5 values to c.jsp. when I sumbit to b.jsp again I will pass the 5 back and change 1 of them b4 that.

Although I feel that it is probably not the most efficient way of doing this.

Bear i am sorry i am still pretty new to this. Everything is being sumbitted by a form method="POST" action="" name="example". when they select the radio button i and selected finished (input button) it is being sumbited back via a javascript function that calls my b.jsp
+Pie Number of slices to send: Send
How do you do this servlet? I am confused by you sumbitting the jsp to it. Do you just submit the data from the jsp? I know your explination is probably very simple to you but i am lost lol.

Thank you,
Randy
+Pie Number of slices to send: Send


This "/SomeURL" is an 'abstracted path name' for your servlet. Map this "SomeURL" to an actual servlet in the web.xml like this (Of course this assuming you are using tomcat servlet container)

<servlet>
<servlet-name>SomeServlet</servlet-name>
<servlet-class>com.somepackage.ActualServlet</servlet-class>
(this is the fully qualified path of the servlet)
</servlet>

Map the above servlet name to a URL using a mapping like this :

<servlet-mapping>
<servlet-name>SomeServlet</servlet-name>
<url-pattern>/SomeURL</url-pattern>
</servlet-mapping>


All this assuming you have basic knowledge about servlets and Tomcat container.

Once you are in the servlet you can forward the request to any other resource you want to.

Good luck!
[ June 14, 2006: Message edited by: vishwanath nadimpally ]
Destroy anything that stands in your way. Except this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 1441 times.
Similar Threads
jsp:include
current JSP page v/s current JSP file!!
transfering a value from one jsp page to many jsp pages
specifying the exact location to display a jsp
passing hidden field in jsp
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 13:02:52.