You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Christian Nelson <cn...@slac.com> on 2002/08/28 09:09:01 UTC

Tag Confusion

Greetings,

I'm new to struts and would like to start off by saying it's an absolute
joy to work with.  I'm creating a new dynamic home page as a pet project,
and will soon start developing a real commercial system using struts.
Great work guys!!!

I have a question however, and I can't figure out what's going wrong
despite reading the various documents out there.

I recently switched to using <html:link> tags from <a href></a>, and am
having some trouble with adding dynamic parameters.

Here is the error I'm getting:

javax.servlet.jsp.JspException: Cannot create rewrite URL: java.net.MalformedURLException: You must specify exactly one of "forward", "href", or "page"
        at org.apache.struts.taglib.html.LinkTag.calculateURL(LinkTag.java:490)
        at org.apache.struts.taglib.html.LinkTag.doStartTag(LinkTag.java:350)
	...
        at org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1125)
        at java.lang.Thread.run(Thread.java:536)

Here are some code snippets from the page that's causing me grief:

<logic:iterate id="trip" type="cnelson.beans.travel.TravelData" collection="<%=cnelson.beans.travel.TravelService.tripDetails(orderCode)%>">
<html:link page="/traveldetails.jsp" paramId="id" paramName="trip" paramProperty="id"><%=trip.getTitle()%></html:link>

There is obviously a ton of other stuff in the file, but those two lines
are most important.  The first shows where the trip bean is created, and
the second is where I'm getting my problem.  I have attached the complete
page source for those who need it.

It's important to note that the url that is generated looks correct on the
screen when i mouse over it (http://localhost:8081/traveldetails.jsp?id=1),
it's just when I click on it that it blows up and I get the above
exception.

Also, the link worked correctly before when I was using <a href> instead
of <html:link>.  I switched to the lattre because it offered the 'page'
mode which helped me deal with relative paths.

I'm clearly only using one of the three modes, page, so the exception
confuses me.  Any ideas on what I'm doing wrong... your help is greatly
appreciated.

Cheers,
Christian

---------------------------------------------------------------------------
 Christian 'xian' Nelson                                  cnelson@slac.com
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    "Don't ask yourself what the world needs.  Ask yourself what makes
  you come alive, and go do that, because what the world needs is people
                  who have come alive." -- Howard Thurman
---------------------------------------------------------------------------


RE: Tag Confusion

Posted by John Yu <jo...@scioworks.com>.
At 03:40 pm 28-08-2002, you wrote:
>Change <html:link page="/traveldetails.jsp" ...
>to <html:link href="/traveldetails.jsp" ...
>
>or you could use <html:link forward="oneof.your.global-forwards" ...
>This being the better form as it will call your action class.
>
>Joe

Be careful that using <html:link forward="forwardToAction"> will not setup 
the sub-application context correctly. Therefore, you should not use it in 
subapps.


-- 
John Yu                       Scioworks Technologies
e: john@scioworks.com         w: +(65) 873 5989
w: http://www.scioworks.com   m: +(65) 9782 9610

Scioworks Camino - "Don't develop Struts Apps without it!"


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Tag Confusion

Posted by Joe Latty <jo...@team2media.com>.
Change <html:link page="/traveldetails.jsp" ...
to <html:link href="/traveldetails.jsp" ...

or you could use <html:link forward="oneof.your.global-forwards" ...
This being the better form as it will call your action class.

Joe

-----Original Message-----
From: Christian Nelson [mailto:cnelson@slac.com]
Sent: Wednesday, 28 August 2002 5:09 PM
To: struts-user@jakarta.apache.org
Subject: <html:link .../> Tag Confusion



Greetings,

I'm new to struts and would like to start off by saying it's an absolute
joy to work with.  I'm creating a new dynamic home page as a pet project,
and will soon start developing a real commercial system using struts.
Great work guys!!!

I have a question however, and I can't figure out what's going wrong
despite reading the various documents out there.

I recently switched to using <html:link> tags from <a href></a>, and am
having some trouble with adding dynamic parameters.

Here is the error I'm getting:

javax.servlet.jsp.JspException: Cannot create rewrite URL:
java.net.MalformedURLException: You must specify exactly one of "forward",
"href", or "page"
        at
org.apache.struts.taglib.html.LinkTag.calculateURL(LinkTag.java:490)
        at
org.apache.struts.taglib.html.LinkTag.doStartTag(LinkTag.java:350)
	...
        at
org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1125
)
        at java.lang.Thread.run(Thread.java:536)

Here are some code snippets from the page that's causing me grief:

<logic:iterate id="trip" type="cnelson.beans.travel.TravelData"
collection="<%=cnelson.beans.travel.TravelService.tripDetails(orderCode)%>">
<html:link page="/traveldetails.jsp" paramId="id" paramName="trip"
paramProperty="id"><%=trip.getTitle()%></html:link>

There is obviously a ton of other stuff in the file, but those two lines
are most important.  The first shows where the trip bean is created, and
the second is where I'm getting my problem.  I have attached the complete
page source for those who need it.

It's important to note that the url that is generated looks correct on the
screen when i mouse over it (http://localhost:8081/traveldetails.jsp?id=1),
it's just when I click on it that it blows up and I get the above
exception.

Also, the link worked correctly before when I was using <a href> instead
of <html:link>.  I switched to the lattre because it offered the 'page'
mode which helped me deal with relative paths.

I'm clearly only using one of the three modes, page, so the exception
confuses me.  Any ideas on what I'm doing wrong... your help is greatly
appreciated.

Cheers,
Christian

---------------------------------------------------------------------------
 Christian 'xian' Nelson                                  cnelson@slac.com
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    "Don't ask yourself what the world needs.  Ask yourself what makes
  you come alive, and go do that, because what the world needs is people
                  who have come alive." -- Howard Thurman
---------------------------------------------------------------------------



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>