Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > JSP: request parameters and XML using EL tags

Reply
Thread Tools

JSP: request parameters and XML using EL tags

 
 
James Willmore
Guest
Posts: n/a
 
      12-14-2004
If this isn't the right newsgroup, please be kind when letting me know

I have the following in an XML file:

....
<section name="1">
<question name="1" required="true">
Describe what the Nominee did to be considered for an award
</question>
</section>
....

And have tried the following in a JSP page

<%@ page contentType="text/html" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="x" uri="http://java.sun.com/jsp/jstl/xml" %>
....
<!-- Section 1 Questions (/form/section[@name='1']) -->
<table border="0" summary="Section 1">
<x:forEach select="$doc//*/section[@name='1']/question">
<x:set var="currentXML" select="string(@name)" />
<c:set var="current" value="Section ${currentXML}" />
<tr>
<td class="onlyCell"><xut select="@name" />. (<cut value="${current}" />)
<xut select="." />
</td>
</tr>
<tr>
<td class="onlyCell">
<textarea cols="78" rows="10" name="<cut value="${current}" />"><cut value="${param[${current}]}" /></textarea>
</td>
</tr>
</x:forEach>
</table>
....

The above code doesn't work because it's an invalid EL expression. I want
to be able to give the value entered back to the user if this required
section isn't filled in. The idea is this ... if the XML file changes, I
don't want to go and recode the JSP based upon the changes.

Is this possible using taglibs or do I need to examine a different way of
doing this?

Hopefully, this post makes sense

Jim
 
Reply With Quote
 
 
 
 
Chris Smith
Guest
Posts: n/a
 
      12-14-2004
James Willmore <(E-Mail Removed)> wrote:
> <cut value="${param[${current}]}" />


> The above code doesn't work because it's an invalid EL expression.


Indeed. You should wrap entire EL expressions in ${...}, but not their
subexpressions. Hence:

<cut value="${param[current]}" />

Note that if you're using JSP 2.0, then cut is obsolete. You should
migrate toward just including the EL expression with no tag.

--
www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
 
Reply With Quote
 
 
 
 
Jim
Guest
Posts: n/a
 
      12-15-2004
Works great!

Can you give a JSP 2.0 example of the code provided -or- direct me to
where I can find the answer myself ... please.

Thanks again,

Jim

 
Reply With Quote
 
Jim
Guest
Posts: n/a
 
      12-15-2004
Works great! Thanks.

Can you show a JSP 2.0 example -or- direct me to a document about
migrating to JSP 2.0 ... please?

Jim

 
Reply With Quote
 
Chris Smith
Guest
Posts: n/a
 
      12-15-2004
Jim <(E-Mail Removed)> wrote:
> Can you give a JSP 2.0 example of the code provided -or- direct me to
> where I can find the answer myself ... please.


Sure. Replace:

<cut value="${param[current]}" />

with:

${param[current]}

--
www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Databindings and XML - Binding Text between XML Tags instead of XMLTag Atrribute Information theintrepidfox ASP .Net Web Controls 0 11-26-2007 08:06 PM
Databindings and XML - Binding Text between XML Tags instead of XMLTag Atrribute Information theintrepidfox ASP .Net 0 11-26-2007 12:55 PM
New to XML - to use urls and img tags in xml? Frank Stallone XML 4 03-23-2005 12:05 PM
JSP: pass data to request but not via request parameters? Kai Grossjohann Java 2 12-08-2003 09:48 PM
Re: Accessing Request.InputStream / Request.BinaryRead *as the request is occuring*: How??? Brian Birtle ASP .Net 2 10-16-2003 02:11 PM



Advertisments