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)


tmonteitAsked:
Who is Participating?
 
Weiping DuSenior Web DeveloperCommented:
<c:redirect url="${form.forward}" />  should be good enough.   No need to put c:out inside it
0
 
Peter KwanAnalyst ProgrammerCommented:
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() %>"/>
0
 
Weiping DuSenior Web DeveloperCommented:
Does  <jsp:forward page="${form.forward}"/>   work for you?
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
jaggernatCommented:
try

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

 
0
 
tmonteitAuthor Commented:
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?
0
 
jaggernatCommented:
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>
0
 
jaggernatCommented:
the value of    <c:out value="${form.forward}" />  must be a .jsp

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

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

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


0
 
jaggernatCommented:
oops, good catch owen   :-)
0
 
Weiping DuSenior Web DeveloperCommented:
Thanks. I test it in my WSAD.
Actaully, both <jsp:forward page="<%=form.getForward()%>" />  and  <c:redirect url="${form.forward}" />  work OK.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.