• 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
  • Paul Clapham
  • Ron McLeod
  • paul wheaton
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Piet Souris
Bartenders:
  • salvin francis
  • Mikalai Zaikin
  • Himai Minh

How do I use a <c:out ...> tag in my <input ...> tag?

 
Ranch Hand
Posts: 650
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm using JSTL 1.2 and am trying to incorporate a <c:out ...> tag in my JSP page. What I want to do is use the member value from my backing bean as the value to be displayed for a form input element, and I want any HTML/XML special characters escaped.

In searching for examples (including in the JSTL spec), I can't find any that do what I'm trying to do, and I'm wondering if I'm misunderstanding the usage of the tag.

By the way, I added a simple <c:forEach ...> block to my JSP page, just to make sure that the JSTL stuff is set up correctly, and got the output I was expecting (it just output 10 numbers with <br> line breaks).

My JSP page includes the following useBean line My original (working) input tag looks like this:
Note that the getMemberNameEncoded() method is a special accessor method I created on the Bean to escape any HTML/XML special characters (this additional method is what I'm trying to avoid).

Now, I would like to use the <c:out> tag to get the value from the bean rather than using the JSP Expression. I see the format for the <c:out> tag is supposed to look like this: but I can't see how to get this into the above input element.

Can someone please show me the correct syntax for doing this?

Thanks,
 
Sheriff
Posts: 67530
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
 
Mark E Hansen
Ranch Hand
Posts: 650
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks, Bear. That is intuitive, and I would have sworn I tried it

It is working now.

Best Regards,
 
Greenhorn
Posts: 1
Hibernate Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
After using <input type="hidden" name="contactId" value="<c:out value="${contactForm.contactId}"/>">

My App is not working giving 404 error.
Can any one tell me the reason behind this?
and please tell me the solution this.

Thanks,
Amresh
 
Saloon Keeper
Posts: 23544
161
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch, Tikku!

A "404" error is Page Not Found. It's not a result of an improper use of c:out tags, it's a bad URL. Look at the "action" attribute of your <form> element.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic