• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JSP noob question from a velocity user

 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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:

 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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".
reply
    Bookmark Topic Watch Topic
  • New Topic