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 374,013 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 2,703 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: 3998 | Replies: 6
Reply
Join Date: Oct 2004
Location: San Francisco, CA
Posts: 337
Reputation: paradox814 is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 1
paradox814's Avatar
paradox814 paradox814 is offline Offline
Posting Whiz

is a variable set?

  #1  
Apr 27th, 2005
I am in the process of learning JSP and my question is how do I check to see if a variable exists? The equivalent of this in php would be
[php]if (isset($_POST['someVar']))[/php] or
[php]if (isset($_GET['someVar']))[/php]
any and all help would be appreciated!
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Dec 2004
Location: Lincoln Park, Michigan
Posts: 1,744
Reputation: Comatose is an unknown quantity at this point 
Rep Power: 7
Solved Threads: 107
Colleague
Comatose's Avatar
Comatose Comatose is offline Offline
Moderator

Re: is a variable set?

  #2  
Apr 27th, 2005
I'm pretty sure you can use defined in javascript. You can try:

if (defined(somevariable)) {
   alert(somevariable);
}

I'm not sure, but I think that's accurate.
Reply With Quote  
Join Date: Oct 2004
Location: San Francisco, CA
Posts: 337
Reputation: paradox814 is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 1
paradox814's Avatar
paradox814 paradox814 is offline Offline
Posting Whiz

Re: is a variable set?

  #3  
Apr 28th, 2005
that wont work because i need it to be serverside, otherwise i might as well do it in html/javascript instead of jsp
Reply With Quote  
Join Date: Dec 2004
Location: Lincoln Park, Michigan
Posts: 1,744
Reputation: Comatose is an unknown quantity at this point 
Rep Power: 7
Solved Threads: 107
Colleague
Comatose's Avatar
Comatose Comatose is offline Offline
Moderator

Re: is a variable set?

  #4  
Apr 28th, 2005
You are talking about a regular variable right? Or are you talking about an evirionment variable?
Reply With Quote  
Join Date: Nov 2004
Location: Netherlands
Posts: 5,588
Reputation: jwenting is a jewel in the rough jwenting is a jewel in the rough jwenting is a jewel in the rough jwenting is a jewel in the rough 
Rep Power: 18
Solved Threads: 187
Colleague
jwenting's Avatar
jwenting jwenting is offline Offline
duckman

Re: is a variable set?

  #5  
Apr 28th, 2005
You mean a request or session attribute?
It's easy.

<c:if test="${not empty someVar}">
  <%-- do what you need to do when the attribute is there --%>
</c:if>

Actually if it's just to prevent errors when outputting something you don't need to check, JSTL is smart enough to ignore anything that's not there so
<c:out value="${someVar}"/>
would just output nothing at all if someVar weren't there.
42 Private messages asking for help will be ignored
In the frozen land of Nador they were forced to eat Steve's iMinstrels, and there was much rejoicing.
Reply With Quote  
Join Date: Oct 2004
Location: San Francisco, CA
Posts: 337
Reputation: paradox814 is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 1
paradox814's Avatar
paradox814 paradox814 is offline Offline
Posting Whiz

Re: is a variable set?

  #6  
Apr 28th, 2005
i mean like a get (from url) or posted (client connection) variable
Reply With Quote  
Join Date: Dec 2004
Location: Lincoln Park, Michigan
Posts: 1,744
Reputation: Comatose is an unknown quantity at this point 
Rep Power: 7
Solved Threads: 107
Colleague
Comatose's Avatar
Comatose Comatose is offline Offline
Moderator

Re: is a variable set?

  #7  
Apr 28th, 2005
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 11:00 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC