| Author |
error in execution jsp statements
|
bhaskar reddy.b
Greenhorn
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 <html> <head> <title> Processing get requests with the data</title> </head> <!-- body section of the document --> <body> <% // begin of scriptlet String name= request.getParameter("firstName"); if(name != null) { %> <%-- end scriptlet to insert fixed template data --%> <h1> <%= new java.util.Date() %> Hello <%= name %>, <br/> Welcome to JavaServerPages! </h1> <% } 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" /> </p> </form> <% } %> </body> </html>
|
 |
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
Greenhorn
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? if(name.equals("")) try and see if it works.
|
 |
 |
|
|
subject: error in execution jsp statements
|
|
|