The solution is fine if U are looking at a page that does not contain a
check box
If U are looking at a page that has a check box and it is not marked then a
req.getParameter("SN") would throw a null pointer exception !!!
;-)
Manu
----- Original Message -----
From: Tim Sporcic <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, May 21, 1999 6:35 PM
Subject: Re: Getting Input Data from a Form.
> I don't have an answer to ClassCastException problem, but you could
> probably make life easier on yourself if you used:
>
> String sn = req.getParameter("SN");
>
> All the servlet engines I've used (JRun, ServletExec, Tomcat) will
> parse the form data for you and put it into the parameter array. If you
> are
> getting a null from the call to getParameter(), double check your HTML.
>
>
> ____________________________ S�parateur R�ponse
> ________________________________
> Objet : Getting Input Data from a Form.
> Auteur : "A mailing list for discussion about Sun Microsystem's Java
> Servlet
> API Technology." <[EMAIL PROTECTED]>
> Date : 21/05/99 11:45
>
>
>
>
> Hi to all!!
>
> When i get user input data from a form by using :
>
> public void doPost(HttpServletRequest req, HttpServletResponse res) throws
> ServletException, java.io.IOException
> {
> ...
>
> ServletOutputStream out = res.getOutputStream();
>
> Hashtable postedData =
> HttpUtils.parsePostData(req.getContentLength(),req.getInputStream());
>
> String sn = (String) postedData.get("SN");
>
> out.print(SN);
> ....
> }
>
> I get the error
>
> java.lang.ClassCastException: java.lang.Object
>
> when I submit the data.
>
> The "SN" is the name of a text-box that allows user input, in a HTML Form.
>
> I have confirm that the value associated with the key "SN" is a String, by
> doing :
>
> ...
> Object sn = postedData.get("SN");
>
> out.print( sn.getClass().getName().);
>
> ...
>
> I don't see were the problem is since the method "get" from Hastable
> returns
> an Object, and String is a subclass of Object.
> Maybe it as something to do with the classloader of the servlet?
>
> Does anyone know whats's the problem?
>
> Tanks in advance,
>
> RJCampos.
>
>
___________________________________________________________________________
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the
body
> of the message "signoff SERVLET-INTEREST".
>
> Archives: http://archives.java.sun.com/archives/servlet-interest.html
> Resources: http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
>
>
>
> ----------------------------------------------------------------
> INFORMATION AUTOMATIC VIRUS CHECK (GEMPLUS) No virus known.
> ----------------------------------------------------------------
>
>
>
>
>
>
> ----------------------------------------------------------------
> INFORMATION AUTOMATIC VIRUS CHECK (GEMPLUS) No virus known.
> ----------------------------------------------------------------
>
>
___________________________________________________________________________
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the
body
> of the message "signoff SERVLET-INTEREST".
>
> Archives: http://archives.java.sun.com/archives/servlet-interest.html
> Resources: http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
>
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html