aspose file tools*
The moose likes JSP and the fly likes How to keep values from calling multiple jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "How to keep values from calling multiple jsp" Watch "How to keep values from calling multiple jsp" New topic
Author

How to keep values from calling multiple jsp

Tempora Telora
Ranch Hand

Joined: Jun 20, 2005
Posts: 83
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
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61426
    
  67

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?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Tempora Telora
Ranch Hand

Joined: Jun 20, 2005
Posts: 83
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
vishwanath nadimpally
Ranch Hand

Joined: Jan 25, 2005
Posts: 116
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.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61426
    
  67

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.
Tempora Telora
Ranch Hand

Joined: Jun 20, 2005
Posts: 83
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
Tempora Telora
Ranch Hand

Joined: Jun 20, 2005
Posts: 83
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
vishwanath nadimpally
Ranch Hand

Joined: Jan 25, 2005
Posts: 116


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 ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to keep values from calling multiple jsp