wood burning stoves 2.0*
The moose likes Struts and the fly likes Populating form with String not bean Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Populating form with String not bean" Watch "Populating form with String not bean" New topic

Populating form with String not bean

Wes Hughes
Ranch Hand

Joined: Jul 29, 2002
Posts: 31
I have to popualate a form with a users email, which is obtained from the database. In my Action I set where email is a String. In my jsp I do the following
Unfortunately, this doesn't work, nevermind the fact that its bad practice to include scriplets in jsp. I don't see the need to create a value object here so what do I do?
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
unfortunatly you need a form class for this. This form class can then simply hold the email address.
This info you can retrieve in the entry action and then store it again in the exit action
Like this
entry (retrieve and call setter of form)
-> jsp
-> exit (store form into db again)
The problem you have is that the html:text tag is also only working in a html:form element.
Reinhold Gruber

Joined: Sep 20, 2002
Posts: 12
Hi. I think that

should to the job
Wes Hughes
Ranch Hand

Joined: Jul 29, 2002
Posts: 31
Actually I realized what I need to do is associate the form with the not only the Action that processes the information in the form but also the Action that retrieves the email address for me.
It is sorta covered in the JavaRanch Style Guide.
subject: Populating form with String not bean
Similar Threads
how to add data in request object and pass it to next page?
Getting error on response.getParameter("");
error occuring while use jsp
Problem in Validating array of form field
Servlet Initialization using JSP