Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Struts URL tag issue

 
Joe Harry
Ranch Hand
Posts: 10106
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Guys,

I have a strange issue with using s:url tags to call an action. Below is what I have on one of my jsp page:



When I click the link, I get the following as exception:


When I viewed the rendered html using Mozilla's firebug, I see the following rendered for the anchor tag as shown in the screenshot



How could this be possible then? Bemused!
screenshot_html.png
[Thumbnail for screenshot_html.png]
 
Joe Harry
Ranch Hand
Posts: 10106
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK. Managed to get rid of it. Changed the anchor tag to <a href="<%=request.getContextPath()%>/content/meetUp.action">here....

But why would the s:url not work? And what is the deal with the request.getContextPath()? Do I need to prepend it to all my url links in my app?
 
Richard Golebiowski
Ranch Hand
Posts: 213
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It should work, unless it's not in the"/" namespace.
 
Jesus Mireles
Ranch Hand
Posts: 122
IntelliJ IDE Java Mac
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From your screenshot it looks like its not even rendering html .. its just sptting out what you typed in the jsp ... so I would question if you have the s prefix defined in your jsp.

<%@ taglib prefix="s" uri="/struts-tags" %>

From your comment it looks like you changed it to scriptlet code to get the context path and then the namespace .... it looks like if you had your prefix defined correctly then I'm guessing you can probably do this:

<s:url var="url" action="meetUp" namespace="content"/>
<s:a href="%{url}">here ...</s:a>

Because from your comment it looks like this action is in the content namespace and not the / which would be the default.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic