Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

c:url parsing problems  RSS feed

 
Chris Pat
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello
I am trying to create a dynamic url with jstl and this syntax below is not
working. It is producing the "delete" text in the table cell, however the href is not formed. It is claming an unmatched a ref tag. Can some see where it is?
tia This is TC4.1 jstl 1.0, etc.

<td><a href="<c:url value="/delete1.jsp"><c aram name="id"value="$
{resultAnimal.oid}"/></c:url>"/>Delete</a></td>

I believe it has to do with the nested '""' however I can not see how to escape them. This is with only one parameter, there must be a less tedious way for this or more parameters. tia.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66141
141
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I avoid nesting <c:url> tags inside HTML template text tags because, well, it's just too hard to read and find syntax issues with.

Rather, I'd do something a little easier to debug like:


[ September 16, 2005: Message edited by: Bear Bibeault ]
 
Chris Pat
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Bear
Thank you for such a speedy response. However when I edit the code it is still the same error on the closing </a> Below is a more complete snippet. The word Delete is printed but no href. I am nonplused, of course I am posting, grin

<c:forEach var="resultAnimal" items="${sessionScope.results}"varStatus="status">
<c:url value="/delete1.jsp" var="theUrl">
<c aram name="id"value="${resultAnimal.oid}"/>
</c:url>
<td><a href="${theUrl}"/>Delete</a></td>
<td><c ut value="${resultAnimal.name}"/></td>
<td><c ut value="${resultAnimal.price}"/></td>
<td><c ut value="${resultAnimal.class.name}"/></td>
</c:forEach>
</tr>
Originally posted by Bear Bibeault:
I avoid nesting <c:url> tags inside HTML template text tags because, well, it's just too hard to read and find syntax issues with.

Rather, I'd do something a little easier to debug like:



[ September 16, 2005: Message edited by: Bear Bibeault ]
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66141
141
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the generated HTML for the td?
 
Chris Pat
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Bear
It is running in my IDE, so I would have to package the war and actually run it. It is simple enough it is a three row table with the second row created by the forEach. The second row, first column is the word Delete. The rest of the columns in that row are the correct values of the properties of the object.

Should I use the html:link tag, but then I would have create a map for the parameterNames and I am not clear on how to do that. JSTL should work? tia.

Originally posted by Bear Bibeault:
What is the generated HTML for the td?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66141
141
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is running in my IDE, so I would have to package the war and actually run it


Is it not displaying it in a browser? Perform a View Source to see what is actually being generated.
 
Chris Pat
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Bear
Here it is:

<center>
<table border="1" width="80%">
<tr><th> </th><th>Name</th><th>Price</th><th>Type</th><th>Details</th></tr>
<!--pull down the resultIterator & the index array and form the table -->

<!--will it pull and convert the Integer wrapper -->


<tr>
<td><a href="${theUrl}"/>Delete</a></td>
<td>Dog from min.jdo</td>
<td>1.0</td>
<td>min05.jdo.Dog</td>
</tr>

<tr><th colspan="5">

1 animals found.
</th>
</tr>
</table>
</center>


Originally posted by Bear Bibeault:


Is it not displaying it in a browser? Perform a View Source to see what is actually being generated.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66141
141
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ah, the EL expression is not being evaluated. What JSP engine are you running? Apparently it is not JSP 2.0 capable.

You'll need to wrap the expression in a <cut> -- so much for increased readability.
[ September 16, 2005: Message edited by: Bear Bibeault ]
 
Chris Pat
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Bear
Well it looks like I will have to migrate to TC5.5. I have been reluctant b/c unclear to what changes I need in the tag lib uri and in the web.xml. Can you detail?

Also when I try below, I still get an error about </a>, and the source looks like 2nd below. tia.

<td><a href="<c ut value="${theUrl}"/>"Delete</a></td>

2nd
<tr>
<td><a href="/min05/delete1.jsp?id=min05.jdo.Animal-50"Delete</a></td>
<td>Dog from min.jdo</td>
<td>1.0</td>
<td>min05.jdo.Dog</td>
</tr>


Originally posted by Bear Bibeault:
Ah, the EL expression is not being evaluated. What JSP engine are you running? Apparently it is not JSP 2.0 capable.

You'll need to wrap the expression in a <c ut> -- so much for increased readability.

[ September 16, 2005: Message edited by: Bear Bibeault ]
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66141
141
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use Tomcat 5.0 or 5.5; the latter for Java 1.5.

Looks like you are missing a > in your HTML.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66141
141
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you upgrade to Tomcat 5, do not forget to upgrade your JSTL implementation to JSTL 1.1, and to update your web.xml to use the Servlets 2.4 xml schema.

Be sure to snag copies of the Servlets 2.4, JSP 2.0 and JSTL 1.1 specifications from the Sun site.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!