Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Populating bean from servlet  RSS feed

 
Will Sillmon Jr.
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What do you mean by "passed them to a servlet with a bean"?
Are you posting the form to the JSP and then using response.forward to pass the context to the servlet?
 
Will Sillmon Jr.
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Will Sillmon Jr.
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
request.getParameter(String) is used to extract the HTML form parameters from the request.

You can add them to your bean using the bean's setter methods.
Then bind the bean to request with:
request.setAttribute(String name, Object bean);

From the JSP, you can print the bean's properties using EL:

${beanName.property}
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!