You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Giovanni Azua <gi...@imc.nl> on 2007/11/29 12:07:29 UTC
adding validation leads to NullPointerException
hi,
I have a JSP (snippet below) that works fine without validation, I need
to conditionally include certain
fields, I prefer that to the other choice of having two different copies
of slightly similar input form JSP
that I will then have to keep in sync.
Only when I add a validation xml file corresponding to the target Action
I get the
NullPointerException stacktrace below.
TIA,
regards,
Giovanni
****************************** stacktrace
***********************************
SEVERE: Servlet.service() for servlet jsp threw exception
java.lang.NullPointerException
at
org.apache.jsp.jsp.form.formAngleAlgoConf_jsp._jspService(formAngleAlgoConf_jsp.java:105)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:393)
at
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at
org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:654)
at
org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:557)
at
org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:481)
...
at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:581)
at
org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:619)
Nov 29, 2007 12:04:07 PM
org.apache.tiles.jsp.context.JspTilesRequestContext include
SEVERE: JSPException while including path
'/jsp/form/formAngleAlgoConf.jsp'.
javax.servlet.jsp.JspException: ServletException while including page.
at org.apache.tiles.jsp.context.JspUtil.doInclude(JspUtil.java:102)
at
org.apache.tiles.jsp.context.JspTilesRequestContext.include(JspTilesRequestContext.java:88)
at
org.apache.tiles.jsp.context.JspTilesRequestContext.dispatch(JspTilesRequestContext.java:82)
at
org.apache.tiles.context.TilesRequestContextWrapper.dispatch(TilesRequestContextWrapper.java:72)
at
org.apache.struts2.tiles.StrutsTilesRequestContext.dispatch(StrutsTilesRequestContext.java:87)
at
org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:465)
...
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:261)
at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:581)
at
org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:619)
Caused by: org.apache.jasper.JasperException: An exception occurred
processing JSP page /jsp/form/formAngleAlgoConf.jsp at line 6
3: <%@ taglib prefix="sx" uri="/struts-dojo-tags" %>
4:
5: <s:form action="%{targetAction}" method="post" theme="%{currentTheme}">
6: <% if (request.getAttribute("buttonLabel").equals("Simulate")) { %>
7: <!-- fields required only for Simulation -->
8:
9: <sx:datetimepicker label="Begin Date" name="beginDate"
displayFormat="yyyy.MM.dd" toggleType="fade" toggleDuration="500" />
Stacktrace:
at
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:524)
at
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:435)
at
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at
org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:654)
****************************** mypage.jsp
***********************************
<%@ page contentType="text/html; charset=UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="sx" uri="/struts-dojo-tags" %>
<s:form action="%{targetAction}" method="post" theme="%{currentTheme}">
<% if (request.getAttribute("buttonLabel").equals("Simulate")) { %>
<!-- fields required only for Simulation -->
<sx:datetimepicker label="Begin Date" name="beginDate"
displayFormat="yyyy.MM.dd" toggleType="fade" toggleDuration="500" />
<sx:datetimepicker label="End Date" name="endDate"
displayFormat="yyyy.MM.dd" toggleType="fade" toggleDuration="500" />
<% } else { %>
<!-- fields required only for CRUD operations -->
<s:textfield tooltip="Provide a name" label="Name"
cssStyle="width: 250px;" name="name" />
<% } %>
<sx:datetimepicker label="On Time" tooltip="Provide the On Time"
name="onTime" type="time" toggleType="fade" toggleDuration="500" />
<sx:datetimepicker label="Off Time" tooltip="Provide the Off Time"
name="offTime" type="time" toggleType="fade" toggleDuration="500" />
// etc etc
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: adding validation leads to NullPointerException
Posted by j alex <st...@gmail.com>.
>From the code you've provided it's failing at
request.getAttribute("buttonLabel").equals("Simulate"))
Can you please specify how/where "buttonLabel" is set in the code.
The only thing i can think of is that validation is stopping the flow to
execute() and some variable set there may not be visible when you are
redirected to the jsp - which would have been set normally if the Action
execute() completes fine.
HTH,
Joseph
On Nov 29, 2007 6:07 AM, Giovanni Azua <gi...@imc.nl> wrote:
> hi,
>
> I have a JSP (snippet below) that works fine without validation, I need
> to conditionally include certain
> fields, I prefer that to the other choice of having two different copies
> of slightly similar input form JSP
> that I will then have to keep in sync.
>
> Only when I add a validation xml file corresponding to the target Action
> I get the
> NullPointerException stacktrace below.
>
> TIA,
> regards,
> Giovanni
>
> ****************************** stacktrace
> ***********************************
>
> SEVERE: Servlet.service() for servlet jsp threw exception
> java.lang.NullPointerException
> at
> org.apache.jsp.jsp.form.formAngleAlgoConf_jsp._jspService
> (formAngleAlgoConf_jsp.java:105)
> at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
> at
> org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java
> :393)
> at
> org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
> at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
> at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
> ApplicationFilterChain.java:290)
> at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(
> ApplicationFilterChain.java:206)
> at
> org.apache.catalina.core.ApplicationDispatcher.invoke(
> ApplicationDispatcher.java:654)
> at
> org.apache.catalina.core.ApplicationDispatcher.doInclude(
> ApplicationDispatcher.java:557)
> at
> org.apache.catalina.core.ApplicationDispatcher.include(
> ApplicationDispatcher.java:481)
> ...
> at
> org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(
> Http11Protocol.java:581)
> at
> org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
> at java.lang.Thread.run(Thread.java:619)
> Nov 29, 2007 12:04:07 PM
> org.apache.tiles.jsp.context.JspTilesRequestContext include
> SEVERE: JSPException while including path
> '/jsp/form/formAngleAlgoConf.jsp'.
> javax.servlet.jsp.JspException: ServletException while including page.
> at org.apache.tiles.jsp.context.JspUtil.doInclude(JspUtil.java:102)
> at
> org.apache.tiles.jsp.context.JspTilesRequestContext.include(
> JspTilesRequestContext.java:88)
> at
> org.apache.tiles.jsp.context.JspTilesRequestContext.dispatch(
> JspTilesRequestContext.java:82)
> at
> org.apache.tiles.context.TilesRequestContextWrapper.dispatch(
> TilesRequestContextWrapper.java:72)
> at
> org.apache.struts2.tiles.StrutsTilesRequestContext.dispatch(
> StrutsTilesRequestContext.java:87)
> at
> org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java
> :465)
> ...
> at
> org.apache.catalina.core.StandardEngineValve.invoke(
> StandardEngineValve.java:109)
> at
> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java
> :261)
> at
> org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
> at
> org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(
> Http11Protocol.java:581)
> at
> org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
> at java.lang.Thread.run(Thread.java:619)
> Caused by: org.apache.jasper.JasperException: An exception occurred
> processing JSP page /jsp/form/formAngleAlgoConf.jsp at line 6
>
> 3: <%@ taglib prefix="sx" uri="/struts-dojo-tags" %>
> 4:
> 5: <s:form action="%{targetAction}" method="post" theme="%{currentTheme}">
> 6: <% if (request.getAttribute("buttonLabel").equals("Simulate")) { %>
> 7: <!-- fields required only for Simulation -->
> 8:
> 9: <sx:datetimepicker label="Begin Date" name="beginDate"
> displayFormat="yyyy.MM.dd" toggleType="fade" toggleDuration="500" />
>
> Stacktrace:
> at
> org.apache.jasper.servlet.JspServletWrapper.handleJspException(
> JspServletWrapper.java:524)
> at
> org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java
> :435)
> at
> org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
> at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
> at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
> ApplicationFilterChain.java:290)
> at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(
> ApplicationFilterChain.java:206)
> at
> org.apache.catalina.core.ApplicationDispatcher.invoke(
> ApplicationDispatcher.java:654)
>
> ****************************** mypage.jsp
> ***********************************
>
> <%@ page contentType="text/html; charset=UTF-8"%>
> <%@ taglib prefix="s" uri="/struts-tags"%>
> <%@ taglib prefix="sx" uri="/struts-dojo-tags" %>
>
> <s:form action="%{targetAction}" method="post" theme="%{currentTheme}">
> <% if (request.getAttribute("buttonLabel").equals("Simulate")) { %>
> <!-- fields required only for Simulation -->
>
> <sx:datetimepicker label="Begin Date" name="beginDate"
> displayFormat="yyyy.MM.dd" toggleType="fade" toggleDuration="500" />
> <sx:datetimepicker label="End Date" name="endDate"
> displayFormat="yyyy.MM.dd" toggleType="fade" toggleDuration="500" />
> <% } else { %>
> <!-- fields required only for CRUD operations -->
>
> <s:textfield tooltip="Provide a name" label="Name"
> cssStyle="width: 250px;" name="name" />
> <% } %>
>
> <sx:datetimepicker label="On Time" tooltip="Provide the On Time"
> name="onTime" type="time" toggleType="fade" toggleDuration="500" />
> <sx:datetimepicker label="Off Time" tooltip="Provide the Off Time"
> name="offTime" type="time" toggleType="fade" toggleDuration="500" />
>
>
> // etc etc
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>