• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

JSP forward tag

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Forget Steve. Look at this tiny ad:
New web page for Paul's Rocket Mass Heaters movies
https://coderanch.com/t/785239/web-page-Paul-Rocket-Mass
reply
    Bookmark Topic Watch Topic
  • New Topic