checkbox error
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   user_2003
Posted On:   Tuesday, March 4, 2003 07:50 AM

I am trying to generate dynamically the values for a checkbox. here is the code I have in my jsp I have the following code in actionForm private static String[] married = {"once","twice","more"}; private String[] selectedItems ={""}; public String[] getSelectedItems() { return (this.selectedItems); } public void setSelectedItems(String[] selectedItems) { this.selectedItems = selectedItems; } trying to run the jsp gives me the following error: java.lang.NullPointerException at java.util.Hashtable.get(Hashtab   More>>


I am trying to generate dynamically the values for a checkbox.

here is the code I have in my jsp

			










I have the following code in actionForm
			
private static String[] married = {"once","twice","more"};
private String[] selectedItems ={""};

public String[] getSelectedItems() {
return (this.selectedItems);
}
public void setSelectedItems(String[] selectedItems) {
this.selectedItems = selectedItems;
}



trying to run the jsp gives me the following error:


			
java.lang.NullPointerException
at java.util.Hashtable.get(Hashtable.java:326)
at org.apache.jasper.runtime.PageContextImpl.findAttribute(PageContextImpl.java:337)
at org.apache.struts.util.RequestUtils.lookup(RequestUtils.java:444)
at org.apache.struts.util.RequestUtils.lookup(RequestUtils.java:491)
at org.apache.struts.taglib.logic.IterateTag.doStartTag(IterateTag.java:302)
at _submit_jsp_10._jspService(submit.jsp :21)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:142)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.jasper.runtime.JspServlet$JspServletWrapper.service(JspServlet.java:300)
at org.apache.jasper.runtime.JspServlet.serviceJspFile(JspServlet.java:430)
at org.apache.jasper.runtime.JspServlet.service(JspServlet.java:565)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.ibm.servlet.engine.webapp.StrictServletInstance.doService(ServletManager.java:827)
at com.ibm.servlet.engine.webapp.StrictLifecycleServlet._service(StrictLifecycleServlet.java:167)
at com.ibm.servlet.engine.webapp.IdleServletState.service(StrictLifecycleServlet.java:297)
at com.ibm.servlet.engine.webapp.StrictLifecycleServlet.service(StrictLifecycleServlet.java:110)
at com.ibm.servlet.engine.webapp.ServletInstance.service(ServletManager.java:472)
at com.ibm.servlet.engine.webapp.ValidServletReferenceState.dispatch(ServletManager.java:1012)
at com.ibm.servlet.engine.webapp.ServletInstanceReference.dispatch(ServletManager.java:913)
at com.ibm.servlet.engine.webapp.WebAppRequestDispatcher.handleWebAppDispatch(WebAppRequestDispatcher.java:523)
at com.ibm.servlet.engine.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java:282)
at com.ibm.servlet.engine.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:112)
at com.ibm.servlet.engine.srt.WebAppInvoker.doForward(WebAppInvoker.java:91)
at com.ibm.servlet.engine.srt.WebAppInvoker.handleInvocationHook(WebAppInvoker.java:184)
at com.ibm.servlet.engine.invocation.CachedInvocation.handleInvocation(CachedInvocation.java:67)


any idea why this is happening?

I took this example from the book "Struts in action", but not sure if anything I am missing...

can anyone help please    <<Less

Re: checkbox error

Posted By:   Anonymous  
Posted On:   Tuesday, March 4, 2003 08:08 AM

Hi


I Think that the problem is in the tag iterate, because you don't have specified the attribute scope ( session ).


It seems that the attribute is search in the scope "page".


In my opinion, it's better to initialize your object in the constructor of the actionForm than in the declaration of your object.


but it's only my point of view.


@+

About | Sitemap | Contact