Win a copy of Micro Frontends in Action this week in the Server-Side JavaScript and NodeJS forum!

Will Sillmon Jr.

+ Follow
since Aug 25, 2005
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Will Sillmon Jr.


session.setAttribute( "thisIsTheNameOfTheVariable", variableData );


So is there a need for me to declare "thisIsTheNameOfTheVariable" or does this statement do it for me. I guess that's what I was trying to do in the previous code that I provided.
14 years ago
Is there a way to seperate what fields should be kept as request scope and which should be applied to the session. The only reason why I am using session scope is because there will be a login screen that must be completed before you are able to access this screen. Should I just keep the items on that screen session scope and make these fields request?
14 years ago
I am basically in "trial and error" mode right now. All of the research that I have done has turned up nothing but "how to display session information" or another "very specific" situation that does not pertain to mine.

If you could guide me in the direction of how to take those fields coming from a query and add them to a session, it would be greatly appreciated. I

Better yet... here's the deal...

1.) form one: company and key input field that is sent to servlet.

2.) servlet: takes company and key and runs query on them and retuns a 180 char string called myResponse.

3.)myResponse: subString is used to divide string into different fields and each field is then given a name.

4.)Desc and Data: are two field that comes from myResponse that needs to be sent to new HTML/JSP for display to the user. Currently being done inside of the servlet but should eventually be done in JSP. (just taking one step at a time)..

5.)ALL DATA needs to be kept in session because it may be used in future screens
Any suggestions....
14 years ago
So what goes where?? Ok.... The two field that were populated from the query are as follows...

String data = myResponse.substring(164, 183);
String desc = myResponse.substring(184, 233);

*myResponse is the string that is returned from the table query*

I tried using:

String sessionData = "";

String sessionDesc = "";

I then used:

<p align=left><FONT size=3><B><font face=Arial, Helvetica, sans-serif>Data: " + sessionData +" </font></B></FONT></TD>"

to display the data on the output of the servlet....

It did not work... what am I doing wrong.
14 years ago
The results that I get back from the query come in a string. I have used substring to take out the data that I need from this string and given them names. How do I take that new field name from the substring and place it in a session. Hope this clears up any misunderstanding.

I tried using what you suggested but I could only get it to work when I was dealing with info from the original form... not from data that is NOT entered from a user...

Maybe a better question would be.. " how do you take predefined variables and add them to the current session?"

I tried to make this as clear as I could... THANKS IN ADVANCE..
14 years ago
I have four fields that I am trying to add to a session. Two of the fields are provided by the user and passed to a servlet. I know how to post them to a JSP:

String sessionKey = (String) session.getAttribute("Key");

<p align=left><FONT face=Arial, Helvetica, sans-serif><B>Company</B><strong>:</strong><strong> " + sessionKey + "</strong></font></FONT></p>

My servlet takes this information from the form and returns values for two new variables... the results come from information returned from a query to a table.

I have these variable occupied with the correct information but I don't know how to add them to a session so I can pass them to the results screen using the same type of code above. I know how to do this using a bean but I am asked to do this using sessions.... HELP!!!
14 years ago
Sorry Ben.. but I overlooked the question you asked....

But no.. I am not. I currently have just been able to populate the bean and display what the user has entered.... I don't know how to make the servlet use the user-entered info and process it.
14 years ago
I guess what I'm really trying to ask is... how do I get a servlet to get information from a bean that has four fields, two that are populated by user input and the other two that needs to be populated from information returned in the form of a string.
14 years ago
How do you populate a bean using values from a substring returned from a socket connection?

I have a JSP form that uses 2 inputs and passed them to a servlet using a bean. The bean is setup to hold 4 fields though..(the other two being my results to be passed back to the "results" page.

I have a servlet that sets up a socket to the mainframe and returns a string from the info entered on the first JSP. I used substring() to name each field in the string and I now want to send the two "new" fields to a jsp to display my results my results.

Any suggestions?
[ December 20, 2005: Message edited by: Bear Bibeault ]
14 years ago
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
14 years ago
The MVC architecture is what I plan on using. What code would I use inside of "final" form to display the values sent from a Servlet.

Maybe that question will help clear up my problem. This is what I have now.

Here is code from servlet:
String desc = myResponse.substring(184, 233);
String nextJSP = "/jspforward.jsp";
RequestDispatcher dispatcher = getServletContext().getRequestDispatcher(nextJSP);

Here is code from jspforward.jsp:
<p align=left><FONT face=Arial><strong>DescriptionX:</strong></font>
<input name=DESC type=text id=DESC size=50 maxlength=50 value='" + desc + "'>

This just displays " + desc +" inside of the text box when sent back to the browser.
14 years ago
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.
14 years ago
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...

Will gladly display code if asked...
14 years ago
I understand the argument that this situation creates but which do you feel is better when dealing with style sheets... I have not attempted to use CSS on the application that I am building but a "heads-up" on this situation would be greatly appreciated...

14 years ago