This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Struts and the fly likes JSP noob question from a velocity user Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "JSP noob question from a velocity user" Watch "JSP noob question from a velocity user" New topic
Author

JSP noob question from a velocity user

Dan Howard
Ranch Hand

Joined: Feb 22, 2004
Posts: 47
Hi All,

We have a mature application running struts 1.2 and velocity and I need to covert a page from a vm to a jsp.

So I modified my struts-config to change the forward to a new JSP file and in the JSP I try to display some data assigned to the form bean but all the form properties show empty in the JSP. When I look at the form itself I see that they are different objects. So somehow the form bean I used in my Action is not the same one that the JSP sees.

Any ideas?


in my JSP I'm just trying this:

David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

The "id" attribute is the instance name of the bean--if you aren't explicitly putting in to scope under that name (no way to tell if you are or not) then it's going to create a new instance of the form bean.

BTW, I recommend against using non-canonical taglib prefixes ("h" and "b" in your case), I can't even figure out why "h" would be chosen for XML tags. It also seems like you're using two different JSTL versions based on the core and XML taglib URIs--it might work, but it strikes me as risky.
Dan Howard
Ranch Hand

Joined: Feb 22, 2004
Posts: 47
How do I specify that "schedule" is the form ID? In the action somewhere?

All I'm doing is this:



struts action mappings?
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Hmm, it's either under the name you specified in the action mapping, or under a constant key--I haven't used Struts 1 for a long time; I don't recall. Easy enough to try both.
Dan Howard
Ranch Hand

Joined: Feb 22, 2004
Posts: 47
Thanks!

I see what it is. In Struts config I named the form scheduleDisplayForm and in the jsp I used the name "schedule". I need to keep the naming from the struts config to get the same objects.

Yes I am a jsp noob - just playing around right now with various tag libs. What are the recommended ones now for tomcat 6.0.20?

David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Well, using the latest JSTL is recommended (the URIs have the "jsp" portion), and where JSTL functionality overlaps with Struts tags functionality, use the JSTL tags.

The normal prefix for the XML tags is "x", the bean tags are generally prefixed with "bean".
 
Don't get me started about those stupid light bulbs.
 
subject: JSP noob question from a velocity user