Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSP forward tag

 
Rashmi Gowda
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Iam getting this error message at line 1: 'Unterminated forward tag'when i try to compile this code:
<jsp:forward page="Import.jsp">
<jsp aram name="noFilename" value="<%=nofilename%>"/>
</jsp:forward>
Iam using Tomcat 3.2beta7 server,forte1.0 as the tool and jdk1.3.
Can anybody please help me figure out why iam getting this error.
Thanks,
Rashmi
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13064
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
" line 1: 'Unterminated forward tag'when i try to
compile this code:
<jsp:forward page="Import.jsp">
"
It is trying to tell you that the tag should be terminated like this:
<jsp:forward page="Import.jsp" />
All of the XML style tags have to be terminated properly.
Bill
 
P SOLAIAPPAN
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I created 2 files
"one.jsp"
<jsp:forward page="two.jsp">
<jsp aram name="noFilename" value="HI WORLD"/>
</jsp:forward>
"two.jsp"
<% out.println(request.getParameter("noFilename")); %>
Similar to your above example, it is printing
HI WORLD
when I executed
"http://localhost:8080/one.jsp"
It appears the problem is in
value="<%=nofilename%>"
If you give your full code, then it will be easier to debug
solaiappan
 
Rashmi Gowda
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Bill and Solaiappan,
Solaiappan,here is the code.
What iam trying to do is:
Iam performing validation to check the filename is not left empty by the user.
If it is left empty ,redirect him to the samepage with an error message.

<%! public final static String NULL_FILE="Please enter a filename";%>
<% String nofilename = " ";%>;
<%-- Get the filename here--%>
String file=request.getParameter("Filename");
<%-- if there is no entry for filename,prompt user to enter some name ,redirect him to the same page --%>
if(file.equals(""))
{
nofilename=NULL_FILE;
}
if(!(nofilename.length()=='0'))<%{%>
<jsp:forward page="Import.jsp">
<jsp aram name="noFilename" value="<%=nofilename%>"/>
</jsp:forward>
<% } %>
Thanks,
Rashmi
 
P SOLAIAPPAN
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Your above code contain multiple errors. I have give sample code below you can try it.
(a)
"FileName.html"
<html>
<head>
<title>File Name</title>
</head>
<body>
<form method="post" action="FileName.jsp">
<br>
<center>
<br>
<b>
Enter File name here:
<input name="fileName" type="text">
<br>
<input type="submit" name="submit" value="ENTER">
</b>
</center>
</form>
</body>
</html>
(b)
FileName.jsp
<%-- Get the filename here--%>
<% String file=request.getParameter("fileName"); %>
%>;
<%-- if there is no entry for filename,prompt user to enter some name ,redirect him to the same page --%>
<%
if(file.equals("")) {%>
<jsp:forward page="FileName.html"/>
<%}
if(file.length()!=0) {%>
<jsp:forward page="Import.jsp">
<jsp aram name="noFilename" value="<%=file%>"/>
</jsp:forward>
<% } %>

(c)
Import.jsp
<% out.println(request.getParameter("noFilename")); %>
When you execute
"http://localhost:8080/FileName.html"
You can enter some filename or leave blank and press enter
If the file name is entered , it will be echoed back, If nothing is entered then the same page will be displayed.
solaiappan
 
Rashmi Gowda
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Solaiappan,
There must be some problem with the IDE recognising the forward tag with parameters.i copied your code and pasted it,it shows the same compiler error.
But anyway it allows me to execute the filename.html page.and even my code gets executed with the same compiler error.
Thanks for taking your time to solve this problem.
Thanks once again,
Rashmi
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic