This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Struts and the fly likes convert struts form value to an integer value Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "convert struts form value to an integer value" Watch "convert struts form value to an integer value" New topic
Author

convert struts form value to an integer value

Kim Kantola
Ranch Hand

Joined: May 17, 2001
Posts: 274
Hi Gang,
I am trying to do the following within a jsp page:
1. get a String value from a struts form
2. convert the String to an int value
3. Use the int to construct a new object within a scriptlet.

Here is my code, can anyone tell me a way to make this work? Thanks so much in advance.

Marc Peabody
pie sneak
Sheriff

Joined: Feb 05, 2003
Posts: 4727



A good workman is known by his tools.
Kim Kantola
Ranch Hand

Joined: May 17, 2001
Posts: 274
Thank you so much Marc.

If you reference the Struts form with a <jsp:useBean> tag, can you use the form name directly without getting it from the session like this?

<jsp:useBean id="ResourceEditForm" class="com.bitpipe.bpES.struts.form.ResourceEditForm" />

User user = new User(Integer.parseInt(ResourceEditForm.getUserId()));
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: convert struts form value to an integer value
 
Similar Threads
Does not found Requested resource....???
generics and maps
blank page - Action is not called
No getter method for property: "userName" of bean: "result"
struts Action for asynchronous HTTP processing