Link to home
Start Free TrialLog in
Avatar of tmonteit
tmonteitFlag for Afghanistan

asked on

JSP Forward Problem


I think I'm using the proper syntax on a <jsp:forward>.  But its giving me an error.

How do I fix this?
<% if(myVariable.equals("X")){ %>
          <jsp:forward page="<c:out value="${form.forward}" />            " />
<%} %>

ERROR

500 Servlet Exception

javax.servlet.jsp.JspException: ServletException in '/jsp/myJSP.jsp':
ServletException in '/jsp/classroom/classLayout.jsp': ServletException
in '/jsp/classroom/content.jsp': /jsp/myJSP.jsp':106: expected
`>' at ``$'' (for tag `<jsp:forward>' at line 106).  The XML tag syntax
is: <tag attr1='value1'>
      at org.apache.struts.taglib.tiles.InsertTag$InsertHandler.doEndTag(InsertTag.java:921)
      at org.apache.struts.taglib.tiles.InsertTag.doEndTag(InsertTag.java:460)
      at _jsp._jsp._layout._layout__jsp._jspService(jsp/layout/layout.jsp:25)
      at com.caucho.jsp.JavaPage.service(JavaPage.java:60)
      at com.caucho.jsp.Page.pageservice(Page.java:570)
      at com.caucho.server.dispatch.PageFilterChain.doFilter(PageFilterChain.java:179)
      at com.caucho.server.webapp.DispatchFilterChain.doFilter(DispatchFilterChain.java:115)
      at com.caucho.server.dispatch.ServletInvocation.service(ServletInvocation.java:229)


Avatar of Peter Kwan
Peter Kwan
Flag of Hong Kong image

I think you cannot put a JSTL tag inside jsp:forward tag. You can do the following:

<jsp:forward page="<%= ((MyForm)request.getAttribute("form")).getForward() %>"/>
Does  <jsp:forward page="${form.forward}"/>   work for you?
Avatar of jaggernat
jaggernat

try

<c:if test="${param.myVariable == "X" }">
<c:redirect url="<c:out value="${form.forward}" />" />
</c:if>

 
Avatar of tmonteit

ASKER

Jaggernat,

your solution puts a line that says "url has moved here".  where here is a link to the page I need?

Any way to make it automatically go to that page?
hmm, intresting.

what is the value of     "<c:out value="${form.forward}" />"


redirect normally will forward to the url value.


you can try this too


<c:if test="${param.myVariable == "X" }">
<jsp:forward page="<c:out value="${form.forward}" /> " />
</c:if>
the value of    <c:out value="${form.forward}" />  must be a .jsp

Its an html, file will it work with an html?
oops, I mean how can it work with an html file.  Obviously its not working.
if 'form' is a bean instance, just call it like:

<% if(myVariable.equals("X")){ %>
     <jsp:forward page="<%=form.getForward()%>" />
<%} %>
>>Its an html, file will it work with an html?
It should.

redirect should follow this sytax    <c:redirect url="abc.html"/>  


ASKER CERTIFIED SOLUTION
Avatar of Weiping Du
Weiping Du
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
oops, good catch owen   :-)
Thanks. I test it in my WSAD.
Actaully, both <jsp:forward page="<%=form.getForward()%>" />  and  <c:redirect url="${form.forward}" />  work OK.