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                                  [EMAIL PROTECTED]
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    "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
---------------------------------------------------------------------------

<%@taglib uri='/WEB-INF/tlds/struts-template.tld' prefix='template'%>
<%@taglib uri="/WEB-INF/tlds/struts-html.tld" prefix='html'%>
<%@taglib uri='/WEB-INF/tlds/struts-logic.tld' prefix='logic'%>
<%@taglib uri='http://jsptags.com/tags/navigation/pager' prefix='pg'%>

<template:insert template='/support/normaltemplate.jsp'>
<template:put name='title' content='Christian Nelson / Travel' direct='true'/>
<template:put name='header' content='/support/header.jsp'/>
<template:put name='sidebar' content='/support/sidebar.jsp'/>
<template:put name='footer' content='/support/footer.jsp'/>
<template:put name='content'>

<%
    String order = request.getParameter("order");
    if (order == null) order = "date";

    String TitleUrl    = "<html:link page=\"/" + request.getRequestURI() + 
"?order=title\">Title</html:link>";
    String DateUrl     = "<html:link page=\"/" + request.getRequestURI() + 
"?order=date\">Date</html:link>";

    int orderCode = cnelson.beans.travel.TravelService.DATE_DESCEND;

    if (order.equals("title")) {
        orderCode = cnelson.beans.travel.TravelService.TITLE_ASCEND;
        TitleUrl = "<b>Title</b>";
    } 
    else if (order.equals("date")) {
        orderCode = cnelson.beans.travel.TravelService.DATE_DESCEND;
        DateUrl = "<b>Date</b>";
    }
%>

<table width='100%' border='0' cellspacing='0' cellpadding='2' align='center'>

<tr><td>
<table width='100%' border='0' cellspacing='0' cellpadding='0' align='center'>
<tr>
<td valign='top' width='100%' colspan='4'>
<table width='100%' border='0' cellspacing='0' cellpadding='0' align='center'>
<tr>
<td bgcolor='#ddddcc' align='left' valign='top'><html:img 
page="/images/left-rounded-side.gif" width='10' height='28'/></td>
<td bgcolor='#ddddcc' align='left' valign='middle' width='100%'><font 
color='#660000'><b>Sort By:</b> <%=TitleUrl%> | <%=DateUrl%></font></td>
<td bgcolor='#ddddcc' align='right' valign='middle'>(<html:link 
page="/admin/travel.jsp">add</html:link>)</td>
<td bgcolor='#ddddcc' align='right' valign='top'><html:img 
page="/images/right-rounded-side.gif" width='10' height='28'/></td>
</tr>
</table>
</td>
</tr>
</table>
</td></tr>

<tr><td>
<table width='100%' border='0' cellspacing='0' cellpadding='0' align='center'>
<tr><td valign='top' width='100%' colspan='4'>
<table width='100%' border='0' cellspacing='0' cellpadding='0' align='center'>
<tr>
<td bgcolor='#ddddcc' align='left' valign='top'><html:img 
page="/images/top-left-round-corner.gif" width='10' height='10'/></td>
<td bgcolor='#ddddcc' align='right' valign='top'><html:img 
page="/images/top-right-round-corner.gif" width='10' height='10'/></td>
</tr>
</table>
</td></tr>
</table>

<table width='100%' border='0' cellspacing='0' cellpadding='0' bgcolor='#ddddcc' 
align='center'>

<pg:pager maxPageItems='10'>
<pg:param name='order' value='<%=request.getParameter("order")%>'/>

<logic:iterate id="trip" type="cnelson.beans.travel.TravelData" 
collection="<%=cnelson.beans.travel.TravelService.tripDetails(orderCode)%>">
<pg:item>

<tr bgcolor='#ddddcc'>
<td>
<table width='100%' border='0' cellspacing='3' cellpadding='5' align='center' 
bgcolor='#ddddcc'>
<tr bgcolor='#eeeedd'>
<td valign='top'>
<table width='100%' border='0' cellspacing='0' cellpadding='0' bgcolor='#ffffff'>
<tr bgcolor='#eeeedd'>
<td width='70%'><html:link page="/traveldetails.jsp" paramId="id" paramName="trip" 
paramProperty="id"><%=trip.getTitle()%></html:link></td>
<td width='30%' align='right'><%=new 
java.text.SimpleDateFormat("yyyy-MM-dd").format(trip.getStart())%> >> <%=new 
java.text.SimpleDateFormat("yyyy-MM-dd").format(trip.getEnd())%></td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>

</pg:item>
</logic:iterate>

</table>
<table width='100%' border='0' cellspacing='0' cellpadding='0' align='center' 
bgcolor='#ddddcc'><tr valign='bottom'>
<td bgcolor='#ddddcc' align='left'><html:img 
page="/images/bottom-left-round-corner.gif" width='10' height='10'/></td>
<td bgcolor='#ddddcc' align='right'><html:img 
page="/images/bottom-right-round-corner.gif" width='10' height='10'/></td>
</tr></table>
</td></tr>

<pg:index>
<tr><td>
<table width='100%' border='0' cellspacing='0' cellpadding='0' align='center'>
<tr>
<td valign='top' width='100%' colspan='4'>
<table width='100%' border='0' cellspacing='0' cellpadding='0' align='center'>
<tr>
<td bgcolor='#ddddcc' align='left' valign='top'><html:img 
page="/images/left-rounded-side.gif" width='10' height='28'/></td>
<td bgcolor='#ddddcc' align='left' valign='middle' width='100%'><font 
color='#660000'><b>Page:</b> 
<pg:prev><html:link page="<%=pageUrl%>"><<</html:link> </pg:prev>
<pg:pages>
<%
    if (pageNumber == pagerPageNumber) { 
    %> <b><%=pageNumber%></b> <%
    } else { 
    %> <html:link page="<%=pageUrl%>"><%=pageNumber%></html:link> <%
    }
%>
</pg:pages>
<pg:next> <html:link page="<%=pageUrl%>">>></html:link></pg:next>
</font></td>
<td bgcolor='#ddddcc' align='right' valign='top'><html:img 
page="/images/right-rounded-side.gif" width='10' height='28'/></td>
</tr>
</table>
</td>
</tr>
</table>
</td></tr>
</pg:index>

</pg:pager>

</table>

</template:put>
</template:insert>
--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to