User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the JSP section within the Web Development category of DaniWeb, a massive community of 373,488 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,888 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JSP advertiser: Lunarpages JSP Web Hosting
Views: 486 | Replies: 3
Reply
Join Date: Nov 2007
Posts: 2
Reputation: idgeitman is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
idgeitman idgeitman is offline Offline
Newbie Poster

Something small..

  #1  
Nov 8th, 2007
Hello,

I've been trying to figure this out but still no luck, can anyone see what im doing wrong here?, the if statement just isn't working!

Thanks,

<% String name = request.getParameter("username"); %>

<% if ("name" == null)  { %>
  <jsp:forward page = "invalid.jsp"/>

             <% } %>
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Feb 2006
Posts: 1,351
Reputation: masijade is a jewel in the rough masijade is a jewel in the rough masijade is a jewel in the rough masijade is a jewel in the rough 
Rep Power: 8
Solved Threads: 113
masijade's Avatar
masijade masijade is online now Online
Nearly a Posting Virtuoso

Re: Something small..

  #2  
Nov 8th, 2007
What are you trying to accomplish with
if ("name" == null)
Comparing a string literal to null will always be false.
Java Programmer and Sun Systems Administrator

----------------------------------------------

Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
Reply With Quote  
Join Date: Nov 2007
Posts: 2
Reputation: idgeitman is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
idgeitman idgeitman is offline Offline
Newbie Poster

Re: Something small..

  #3  
Nov 8th, 2007
trying to see is "name" null.
Reply With Quote  
Join Date: Feb 2006
Posts: 1,351
Reputation: masijade is a jewel in the rough masijade is a jewel in the rough masijade is a jewel in the rough masijade is a jewel in the rough 
Rep Power: 8
Solved Threads: 113
masijade's Avatar
masijade masijade is online now Online
Nearly a Posting Virtuoso

Re: Something small..

  #4  
Nov 9th, 2007
Well "name" (when you use quotes) is a value not a variable. So the value "name" will never be equal to the value null.
Java Programmer and Sun Systems Administrator

----------------------------------------------

Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb JSP Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the JSP Forum

All times are GMT -4. The time now is 5:48 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC