File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes calling JSP n times with Different Inputs stored in a Session Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "calling JSP n times with Different Inputs stored in a Session" Watch "calling JSP n times with Different Inputs stored in a Session" New topic
Author

calling JSP n times with Different Inputs stored in a Session

Ven Mahi
Greenhorn

Joined: Jun 13, 2002
Posts: 8
Hi
I Have an application which makes use of an object stored in a Session.
a JSP ex1.jsp includes ex2.jsp(Which will create the object if it is not session and adds it to the session) will produce the html file using the object in the session.
Q1: Now i want to loop through 10 times by changing one of the values of Object stored in the session with out recreating that every time and using ex1.jsp produce results and save it or print it and display the last Results Page
How can i do that, saving, printing, calling same jsp repeatedly using the object in session
[ June 14, 2002: Message edited by: Ven Mahi ]
Ven Mahi
Greenhorn

Joined: Jun 13, 2002
Posts: 8
Any One!!! Help me. I tried the following code but it is not using the values in the session, it is creating a new object ( I check for this another included jsp , if not found in session create new one )every time i call this function from JSP
URL u = new URL("http://localhost:8080/loop.jsp");
URLConnection urlc;
for(int i=0; i< 4;i++)
{
myObject.setItem("MyItem", "MyItem"+i);
urlc = u.openConnection();
urlc.setDoInput(true);
urlc.setDoOutput(true);
urlc.setAllowUserInteraction(true);
DataInputStream in = new DataInputStream(urlc.getInputStream());
pt = new PrintWriter(new FileOutputStream("abcd"+i+".html"));
String s;
while((s = in.readLine()) != null)
{
pt.println(s);
}
[ June 17, 2002: Message edited by: Ven Mahi ]
Ven Mahi
Greenhorn

Joined: Jun 13, 2002
Posts: 8
Any one???
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61764
    
  67

Perhaps you are not being clear on exactly what you are trying to accomplish. It's certainly unusual in the JSP environment and personally I can't make heads or tails out of what you are really trying to accomplish.
Perhaps a higher level description of your objectives might help.
hth,
bear


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Erick Jones
Ranch Hand

Joined: Jun 17, 2002
Posts: 38
I believe that a new session is being created when you open the URL connection. This is essentially a redirect. I think what you really want is to forward using the RequestDispatcher.
Why are you using the session instead of the request? It is a better practice to pass the parameters to the JSP using the request, rather than using the session to hold global information.
Ven Mahi
Greenhorn

Joined: Jun 13, 2002
Posts: 8
Thank you for your replies
I have an application where i will store all my values in a object and use that object to calc and create Html Pages.
I am saving that object in session and that will be used in other JSPS to calc and create Html Pages.
I am saving cases to a database and to batch print all these cases i have to create the Object from Data , store it in session and it will be used by other jsps to create html pages and save them to a file or directly print them some how
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: calling JSP n times with Different Inputs stored in a Session