I'm really frustrated now. Here's the deal... I have a jsp form that submits two fields to a servlet. The servlet then sets up a socket connection to the mainframe, processing my information and returns a string. I have taken the string and used "substring()" to separate the string into different values.
My issue is that I have to figure out how to display this data in a new jsp inside of text boxes so the user can choose(or not choose) to edit the information. I can write the HTML in the servlet but from all of my research...
I keep getting null when I try the request dispatch to forward the values to a new page...
Code would be nice, I'm not sure exactly what your problem is. You can store objects in session variables (although for passing from servlet-to-jsp I wouldn't recommend it). You can have the servlet submit the data to a JSP as it would any form, and then read the data from the JSP using a JSP:bean or using request.getAttribute() to read the data as from a form.
I guess what I'm trying to ask is ... How would I take values from a servlet and display them inside of a form without using println() inside of my servlet. I have a very large application to build and this is my first screen so I am very careful about doing this the right (and most efficient) way...
I send two fields to the servlet from the jsp but I need to return those two PLUS two others that are given from the servlet. One of those new fields needs to be in text box.
I have a real simple MVC example on my site that you can look at to see how I do this if you like. http://simple.souther.us Look for SimpleMVC.
In short, any values that need to be passed from the servlet to the JSP get loaded into a bean, the bean gets bound to request scope (there are other scoping objects too), then the context gets forward to the JSP.
From within the JSP there are several ways to read the values from the bean. The easiest way these days is with EL
[KLUNK!] [ December 15, 2005: Message edited by: Ben Souther ]
P.S. Notice that I also fixed up your HTML notation a bit. Leaving off the quotes for attributes leads to nothing but trouble.
Will Sillmon Jr.
Joined: Aug 25, 2005
Thanks for the reply you guys. I'm checking out the link and I already see it as being a great help. It's one thing to see it in books ... it a total different story when you can see a simplistic example.
Here is the big picture (since I have your attention).... I have to set up a logon jsp that sets different options (other jsp hyperlink accessibility) and diplays them on a "menu" jsp.
From that menu jsp, a user can choose an option (the jsp I'm working on right now for instance).
I'm going to have to keep up with user information, so are beans the best way to do this or do I have any other options...
Forgive the fact that I am still so "wet behind the ears" but I just left the mainframe world so I'm trying the best I know how.. haha
From that menu jsp, a user can choose an option (the jsp I'm working on right now for instance). I'm going to have to keep up with user information, so are beans the best way to do this or do I have any other options...
If you put all this menu information into a bean and bind it to session scope, you can look it up, once, when the user logs in and retain it in memory on the server for the duration of their session. Once their session expires (or if you invalidate the session in response to the user making a logout request), the object is freed for garbage collection.