The piece of code that you have supplied to the list is working fine.
Maybe the error is being generated due to some other lines of code.
A post of the entire jsp file to the list would surely get you a solution
from this list :-).
Have a nice day.
With regards,
Sachin S. Khanna
http://www.emailanorder.com
----- Original Message -----
From: Charles Luo <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, April 23, 2001 4:17 PM
Subject: cookie problems


> Dear mailinglist,
>
> Currently, I am trying to use cookies to store data about site visitors'
> actions.
>
> the logic is that
>
> Cookie[] cookies=request.getCookies();
>
> if (cookies==null || cookies.length==0)  {
>   aCookie=new Cookie(key,"0");
>   aCookie.setMaxAge(60*10);  // expires after 10 minute
>   response.addCookie(aCookie);
> }
>
> ... do somthing here ( modifying the value of key: for example 0 -> 1)
>
> and then
>
> for (int i=0; i<cookies.length; i++){
>         if (cookies[i].getName().equals(key)){
>           cookies[i].setValue("1");
>           cookies[i].setMaxAge(60*30);  // expires after 30 minute
>           response.addCookie(cookies[i]);
> }
>
> ........
>
> When I first run this jsp, it works fine and on the second time, I got
some
> exceptions thrown
>
> Mon Apr 23 11:40:34 BST 2001:<E> <WebAppServletContext-General> exception
> raised on '/polling/bepoll.jsp'
> java.lang.NullPointerException
>         at jsp_servlet._polling._bepoll._jspService(_bepoll.java:230)
>         at weblogic.servlet.jsp.JspBase.service(JspBase.java:27)
>         at
>
weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java
> :123)
>         at
>
weblogic.servlet.internal.ServletContextImpl.invokeServlet(ServletContextImp
> l.java:761)
>         at
>
weblogic.servlet.internal.ServletContextImpl.invokeServlet(ServletContextImp
> l.java:708)
>         at
>
weblogic.servlet.internal.ServletContextManager.invokeServlet(ServletContext
> Manager.java:252)
>         at
>
weblogic.socket.MuxableSocketHTTP.invokeServlet(MuxableSocketHTTP.java:346)
>         at
> weblogic.socket.MuxableSocketHTTP.execute(MuxableSocketHTTP.java:246)
>         at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:135)
>
>
>
> Has any one got this kind of response before? Any comments will be
> appreciated.
>
> Cheers,
> Charles
> -----Original Message-----
> From: Sachin S. Khanna [mailto:[EMAIL PROTECTED]]
> Sent: 23 April 2001 07:54
> To: [EMAIL PROTECTED]
> Subject: Re: <jsp:getProperty> vs <%= bean.getXxx %>
>
>
> The following extract from the jsp1.2 specification clarifies the
behaviour
> witnessed by you ::
>
> "The value of the name attribute in jsp:setProperty and jsp:getProperty
will
> refer to an object that is obtained from the pageContext object through
its
> findAttribute() method.
>
> The object named by the name must have been "introduced" to the JSP
> processor using either the jsp:useBean action or a custom action with an
> associated VariableInfo entry for this name.
>
> Note: a consequence of the previous paragraph is that objects that are
> stored in, say, the session by a front component are not automatically
> visible to jsp:setProperty and jsp:getProperty actions in that page unless
a
> jsp:useBean action, or some other action, makes them visible. "
>
> Based on the above if you add the following line of code to your jsp
> it should generate the output you are looking for :
> pageContext.setAttribute("invoice",invoice);
>
> This line of code should come inside the for loop of your jsp and after
the
> following line of code :
> invoice = invoices[i];
>
> Assume this helps :-).
> Have a nice day.
> With regards,
> Sachin S. Khanna
> http://www.emailanorder.com
> ----- Original Message -----
> From: Gerry Scheetz <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Sunday, April 22, 2001 4:50 AM
> Subject: <jsp:getProperty> vs <%= bean.getXxx %>
>
>
> > I have a JSP file that is
> >
> > <%@ page import="ChildCare.InvoiceBean"
> contentType="text/html;charset=ISO-8859-1" %>
> > <jsp:useBean  id="invoice" class="ChildCare.InvoiceBean" />
> > <% InvoiceBean[] invoices =
> (InvoiceBean[])session.getAttribute("invoices"); %>
> >
> >     <%
> >     for (int i=0; i< invoices.length; i++) {
> >        invoice = invoices[i];
> >     %>
> >
> >     <jsp:getProperty name="invoice" property="invoiceNumber" />
> >     <BR>
> >     <%= invoice.getInvoiceNumber() %>
> >     <P>
> >
> >     <%
> >     }
> >     %>
> >
> > </BODY>
> > </HTML>
> >
> > My bean code is
> >
> > package ChildCare;
> >
> > public class InvoiceBean implements Serializable{
> >   int invoiceNumber;
> >
> >   /**
> >    * Constructor
> >    */
> >   public InvoiceBean() {
> >   }
> >
> >   public int getInvoiceNumber() {
> >     return invoiceNumber;
> >   }
> >
> >   public void setInvoiceNumber(int newInvoiceNumber) {
> >     invoiceNumber = newInvoiceNumber;
> >   }
> > }
> >
> >   I get a 0 returned from <jsp:getProperty name="invoice"
> property="invoiceNumber" />
> >   and I get the invoice number from <%= invoice.getInvoiceNumber() %>
> >
> > I am using Tomcat as my servlet container and JSP engine, apache is my
web
> server.
> >
> > Any idea on why I do not get the invoice number using the getProperty
> command?
> >
> > Side note, why do I have to specify my package name (ChildCare) in the
> useBean command since I included it in
> > my page directive.
> >
> > Thanks,
> >
> >
> >
> > Gerry Scheetz
> > Web Application Development
> > Global Information Technology Division
> > TRW - S&ITG
> > Helena, Montana, USA
> > [EMAIL PROTECTED]
> > (406) 594-1878
> >
> >
>
===========================================================================
> > To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
> JSP-INTEREST".
> > For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST
> DIGEST".
> > Some relevant FAQs on JSP/Servlets can be found at:
> >
> >  http://java.sun.com/products/jsp/faq.html
> >  http://www.esperanto.org.nz/jsp/jspfaq.html
> >  http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
> >  http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
> >
>
>
===========================================================================
> To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
> JSP-INTEREST".
> For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST
> DIGEST".
> Some relevant FAQs on JSP/Servlets can be found at:
>
>  http://java.sun.com/products/jsp/faq.html
>  http://www.esperanto.org.nz/jsp/jspfaq.html
>  http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
>  http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
>
>
===========================================================================
> To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
> For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST
DIGEST".
> Some relevant FAQs on JSP/Servlets can be found at:
>
>  http://java.sun.com/products/jsp/faq.html
>  http://www.esperanto.org.nz/jsp/jspfaq.html
>  http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
>  http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
>

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

Reply via email to