This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes JSP and the fly likes error in execution jsp statements Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Java » JSP
Bookmark "error in execution jsp statements" Watch "error in execution jsp statements" New topic

error in execution jsp statements

bhaskar reddy.b

Joined: Jan 21, 2002
Posts: 8
i had written a simple jsp program
that will ask the user to type the firstname and when u clicks submit it will display the name and some information.
this program should not run if user does not type anything in the textfield because in the program
if(name != null) it should again ask to type but the program is running without typeanything also.
what could be the reason please tell me.
this is the program
<title> Processing get requests with the data</title>
<!-- body section of the document -->
<% // begin of scriptlet
String name= request.getParameter("firstName");
if(name != null) {
%> <%-- end scriptlet to insert fixed template data --%>
<%= new java.util.Date() %>
Hello <%= name %>, <br/>
Welcome to JavaServerPages!

else {
<form action = "Welcome.jsp" method = "get">
<p>Type Your first Name and press Submit </p>
<p><input type = "text" name="firstName" />
<input type = "submit" value="Submit" />
Roy Ben Ami
Ranch Hand

Joined: Jan 13, 2002
Posts: 732
try to print out the String <%=name %> and i think ull see that if the user doesnt input anything the string is not null.
it is just empty! like this "" or " "
so check to see if it is null or empty.
this is just by guessing so i may be wrong .
bhaskar reddy.b

Joined: Jan 21, 2002
Posts: 8
ya i too guessed like that but it is not displaying even "" just nothing.
why it is not checking that
Roy Ben Ami
Ranch Hand

Joined: Jan 13, 2002
Posts: 732
did u try to compare like this?
try and see if it works.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link:
subject: error in execution jsp statements
It's not a secret anymore!