Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within JSP
Search Coderanch
Advance search
Google search
Register / Login
Forums
Register
Login
Java
»
JSP
request.getAttribute
Atef Sarraj
,
Greenhorn
Mar 21, 2012 02:44:59
(0 cow)
(0 skulls)
+Pie
Number of slices to send:
Send
hi alll,
I want
test
if a variable equal to null ,else i will display two button , this variable i will get it from FileAction.java , so i make this in my page
jsp
(File.jsp)
<% if (request.getAttribute("name").toString().equals(null)){ break; } else { %> <html:button property="button2" onclick="document.forms['FileForm'].myAction.value='2'">Mettre à jour</html:button> <html:button property="button3" onclick="document.forms['FileForm'].myAction.value='3'">Annuler</html:button> <% } %>
the error is:
org.apache.jasper.JasperException: An exception occurred processing JSP page /file.jsp at line 24 21: 22: <br> 23: <% 24: if (request.getAttribute("name").toString().equals(null)){ 25: 26: break; 27: Stacktrace: org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:524) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:435) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266) javax.servlet.http.HttpServlet.service(HttpServlet.java:803) cause mère java.lang.NullPointerException org.apache.jsp.file_jsp._jspService(file_jsp.java:119) org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) javax.servlet.http.HttpServlet.service(HttpServlet.java:803) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:393) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266) javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
thanks for help
E Armitage
,
Rancher
Mar 21, 2012 02:50:13
(0 cow)
(0 skulls)
2
+Pie
Number of slices to send:
Send
If the attribute is null then you can't call toString (or any method) on it.
You would use
if (request.getAttribute("name") != null ){
to do the null check.
Consider using EL for these checks. It results in cleaner and easier to read pages.
Atef Sarraj
,
Greenhorn
Mar 21, 2012 03:03:26
(0 cow)
(0 skulls)
+Pie
Number of slices to send:
Send
thanks
Bear Bibeault
,
Sheriff
staff
Mar 21, 2012 08:17:48
(0 cow)
(0 skulls)
+Pie
Number of slices to send:
Send
Java
code in a JSP? In 2012? :shock:
You should
be using the JSTL's <c:if> tag to test the condition, not old-fashioned Java code.
Post by:
autobot
Heroic work plunger man. Please allow me to introduce you to this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
reply
This thread has been viewed 936 times.
Similar Threads
Exception Error Processing JSP Page
JSP BEAN Question
Exception
Problem with Struts html Tags
Logic:iterate
More...
All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 23:18:30
.