Solved

JSP Forward Problem

Posted on 2006-11-18
13
213 Views
Last Modified: 2010-04-01

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)


0
Comment
Question by:tmonteit
  • 5
  • 4
  • 3
  • +1
13 Comments
 
LVL 16

Expert Comment

by:Peter Kwan
ID: 17971840
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
 
LVL 9

Expert Comment

by:owenli27
ID: 17971965
Does  <jsp:forward page="${form.forward}"/>   work for you?
0
 
LVL 10

Expert Comment

by:jaggernat
ID: 17972346
try

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

 
0
Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

 

Author Comment

by:tmonteit
ID: 17973431
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
 
LVL 10

Expert Comment

by:jaggernat
ID: 17973628
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
 
LVL 10

Expert Comment

by:jaggernat
ID: 17973638
the value of    <c:out value="${form.forward}" />  must be a .jsp

0
 

Author Comment

by:tmonteit
ID: 17973705
Its an html, file will it work with an html?
0
 

Author Comment

by:tmonteit
ID: 17973706
oops, I mean how can it work with an html file.  Obviously its not working.
0
 
LVL 9

Expert Comment

by:owenli27
ID: 17974545
if 'form' is a bean instance, just call it like:

<% if(myVariable.equals("X")){ %>
     <jsp:forward page="<%=form.getForward()%>" />
<%} %>
0
 
LVL 10

Expert Comment

by:jaggernat
ID: 17974647
>>Its an html, file will it work with an html?
It should.

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


0
 
LVL 9

Accepted Solution

by:
owenli27 earned 400 total points
ID: 17981580
<c:redirect url="${form.forward}" />  should be good enough.   No need to put c:out inside it
0
 
LVL 10

Expert Comment

by:jaggernat
ID: 17992247
oops, good catch owen   :-)
0
 
LVL 9

Expert Comment

by:owenli27
ID: 17992775
Thanks. I test it in my WSAD.
Actaully, both <jsp:forward page="<%=form.getForward()%>" />  and  <c:redirect url="${form.forward}" />  work OK.
0

Featured Post

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
ajax auto save 15 101
Can I clean log of  running tomcat 7 server ? 3 126
reflections, dynamic class loading 3 70
runtime exception and error differences 4 78
How do we balance the user experience (UX) with reasonable security measures? It can be done, if you keep these fundamentals in mind.
When we purchase storage, we typically are advertised storage of 500GB, 1TB, 2TB and so on. However, when you actually install it into your computer, your 500GB HDD will actually show up as 465GB. Why? It has to do with the way people and computers…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question