| | |
is a variable set?
Please support our JSP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
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!
[php]if (isset($_POST['someVar']))[/php] or
[php]if (isset($_GET['someVar']))[/php]
any and all help would be appreciated!
I'm pretty sure you can use defined in javascript. You can try:
I'm not sure, but I think that's accurate.
JSP Syntax (Toggle Plain Text)
if (defined(somevariable)) { alert(somevariable); }
I'm not sure, but I think that's accurate.
that wont work because i need it to be serverside, otherwise i might as well do it in html/javascript instead of jsp
You mean a request or session attribute?
It's easy.
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
would just output nothing at all if someVar weren't there.
It's easy.
JSP Syntax (Toggle Plain Text)
<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
JSP Syntax (Toggle Plain Text)
<c:out value="${someVar}"/>
As people are clearly allowed to attack me but I'm not allowed to defend myself, I no longer post to this site.
![]() |
Similar Threads
- runtime error 91 object variable or With block variable not set (Visual Basic 4 / 5 / 6)
- 'Object variable or With block variable not set' Error (ASP.NET)
- object variable or with block variable not set (Community Introductions)
Other Threads in the JSP Forum
- Previous Thread: jsp command for open a page
- Next Thread: Jsp doesnt return parameter value
Views: 6857 | Replies: 6
| Thread Tools | Search this Thread |
Tag cloud for JSP
apache array backbutton combobox comma connection csv database development directorystructure dropdownlist dynamicpagetitles eclipse frames glassfish ie8 imagetodatabse imageupload integer internet java javaee javascript jsf jsp jsppagetitles levels mvc2 mvcmodel2 mysql netbeans network parameters passing ping printinserverinsteadofclient project read redirect request.getparameter response seperated servlet servletdopost()readxml sessions software sql ssl state_saving_method stocks sun tomcat tutorial update values video web write






