wood burning stoves 2.0*
The moose likes Servlets and the fly likes JSP forward tag Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "JSP forward tag" Watch "JSP forward tag" New topic
Author

JSP forward tag

Rashmi Gowda
Greenhorn

Joined: Dec 04, 2000
Posts: 5
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

Joined: Mar 22, 2000
Posts: 12761
    
    5
" 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

Joined: Oct 20, 2000
Posts: 68
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

Joined: Dec 04, 2000
Posts: 5
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

Joined: Oct 20, 2000
Posts: 68
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

Joined: Dec 04, 2000
Posts: 5
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JSP forward tag
 
Similar Threads
&lt;jsp:forward&gt; error message
Problem with forward and include JSP tag
Java IO Exception in JSP
forward page and parameter
Error passing data from jsp to servlet