westernind: (Default)
[personal profile] westernind
I've never coded in Java or JSP, and I'm landed with a conversion task.

Is there any outside chance that anyone out there knows how to write JSP Documents (XML-compliant JSP code), knows how to code form input fields, and wouldn't mind answering what's probably a newbie question?


The issue is, the page has to be XML-compliant. Chevron brackets aren't allowed inside XML attributes. So I have to restructure the code.

BEFORE
<input value="<%= email%>" type="text" name="contactEmail" id="emailcontact" size="20"/>

AFTER
Based on googling, this is my best guess:

<jsp:element name="input">
     <jsp:attribute name="name">
          <c:out value="contactEmail"/>
     </jsp:attribute>
     <jsp:attribute name="value">
          <c:out value="$email"/>
     </jsp:attribute>
     <jsp:attribute name="type">
          <c:out value="text"/>
     </jsp:attribute>
     <jsp:attribute name="id">
          <c:out value="emailcontact"/>
     </jsp:attribute>
     <jsp:attribute name="size">
          <c:out value="20"/>
     </jsp:attribute>
</jsp:element>

But it's not quite right. That code successfuly produces an HTML form text input field, but it has a displayed value of $variable. Whereas I need the actual value, as typed in by the user, to be assigned to the JSP variable on submission.

Meep?


[EDITED: solved! the answer is, replace <c:out value="$email"/> with <jsp:expression>email</jsp:expression>

Date: 2007-05-03 02:12 pm (UTC)
From: [identity profile] sack-boy.livejournal.com
A colleague does a lot of this sort of thing - so I have this over to him, but he's busy indoctrinating working with a user atm.

Date: 2007-05-03 02:17 pm (UTC)
From: [identity profile] westernind.livejournal.com
any help would be welcome!

Date: 2007-05-03 02:36 pm (UTC)
From: [identity profile] westernind.livejournal.com
now sorted :-)

Date: 2007-05-03 02:22 pm (UTC)
From: [identity profile] kt-peasant.livejournal.com
Not done JSP, but have you tried it without the " round the variable name? " often mean 'treat everything inside as plain text'

Date: 2007-05-03 02:36 pm (UTC)
From: [identity profile] irdm.livejournal.com
Bit rusty...

There was/is? a Feature whereby paramater substitution for JSTL wasn't enabled by default!!!

Also, (depending on exact environment" should it be "$ { variable } " ?

Am just dashing out, hope fixed by next Tues when back!

Date: 2007-05-03 02:37 pm (UTC)
From: [identity profile] westernind.livejournal.com
Someone IM'ed me - it's sorted :-)
(see above for solution)

Profile

westernind: (Default)
westernind

September 2020

S M T W T F S
  12345
6789101112
13 141516171819
20212223242526
27282930   

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Aug. 2nd, 2025 03:57 pm
Powered by Dreamwidth Studios