westernind (
westernind) wrote2007-05-03 03:04 pm
![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
(no subject)
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>
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>