aspose file tools*
The moose likes JSP and the fly likes Use JavaScript to set form values? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Use JavaScript to set form values?" Watch "Use JavaScript to set form values?" New topic
Author

Use JavaScript to set form values?

rick collette
Ranch Hand

Joined: Mar 22, 2002
Posts: 208
Hi, guys:

I have a JSP page with a form of text boxes and dropdowns. Every time
when a user comes to this page, I will try to set form fields with values I
got from database which are put in session. I know we can use struts ActionFomrm to achieve this, but I cannot use Struts for this somehow. Is there any way I can do this using JavaScript or anything else?

regards,
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
A little JSTL should do the trick:

<input name="myTextField" type="text" value="<cut value="${myBean.myProperty}"/>">

or if you're using a JSP 2.0 web container, simply:

<input name="myTextField" type="text" value="${myBean.myProperty}">
[ March 02, 2006: Message edited by: Merrill Higginson ]

Merrill
Consultant, Sima Solutions
rick collette
Ranch Hand

Joined: Mar 22, 2002
Posts: 208
Originally posted by Merrill Higginson:
A little JSTL should do the trick:

<input name="myTextField" type="text" value="<c ut value="${myBean.myProperty}"/>">

or if you're using a JSP 2.0 web container, simply:

<input name="myTextField" type="text" value="${myBean.myProperty}">

[ March 02, 2006: Message edited by: Merrill Higginson ]


Thanks for the reminder. I guess I can just use JSP expressions to populate form values.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61661
    
  67

Yup, no need to bring in things such as Struts when JSTL and JSP can do it for you.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Use JavaScript to set form values?