You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by vbharath19 <bh...@gs.com> on 2007/06/26 18:03:51 UTC

Form Upload throwing null pointer. cannot retrieve the file in action class..HELP URGENT!!!

Hi,

I have a jsp from which i upload a file. this field is of Formfile type.

jsp entry:

<html:form method="post" enctype="multipart/form-data" 
action="/pages/deploy-action.do" >
<td>	<html:file name="deploymentForm"  property="theFile" />	</td>
	<br>
	<tr>
	<td> <html:submit onclick="upload()" value="Upload the excel" >  
</html:submit> </td>
	</tr>
</html:form>

I have not used bean:define in the jsp. when i use it,it throws cannot
assign null exception.

in the struts config xml, entries are present for form - bean but not for
its property, i tried entering the property, it did not make a difference

I am using the multiform/form-data enctype and also method=post. 

when i run the page and upload the file and invoke the action class i get
the following error.

java.lang.NullPointerException
        at actions.DeployAction.execute(DeployAction.java:139)
        at
org.apache.struts.action.RequestProcessor.processActionPerform(Reques
tProcessor.java:419)
        at
org.apache.struts.action.RequestProcessor.process(RequestProcessor.ja
va:224)
        at
org.apache.struts.action.ActionServlet.process(ActionServlet.java:119
6)
        at
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)


-- 
View this message in context: http://www.nabble.com/Form-Upload-throwing-null-pointer.-cannot-retrieve-the-file-in-action-class..HELP-URGENT%21%21%21-tf3983276.html#a11308662
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Form Upload throwing null pointer. cannot retrieve the file in action class..HELP URGENT!!!

Posted by "vikranth.vaddi" <vi...@gmail.com>.
The problem you have is that struts does not instantiate form bean correctly.
If you are using action form object in your case deployForm object , check
if it extends ActionForm.May be it does not and thats why form object is
null.Try this first.

Also, i recommend using DynaActionForm inside struts-config.xml and do not
create objects for form beans yourselves. Struts will automatically do that
for you.
-- 
View this message in context: http://www.nabble.com/Form-Upload-throwing-null-pointer.-cannot-retrieve-the-file-in-action-class..HELP-URGENT%21%21%21-tf3983276.html#a11315918
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Form Upload throwing null pointer. cannot retrieve the file in action class..HELP URGENT!!!

Posted by vbharath19 <bh...@gs.com>.
done..it doesn't work..any other ideas?

nuwan chandrasoma-2 wrote:
> 
> Hi,
> 
> try removing the .do from your action in the form and just put the action 
> name what is in the struts-config.xml.
> 
> Thanks,
> 
> Nuwan
> 
> 
> ----- Original Message ----- 
> From: "vbharath19" <bh...@gs.com>
> To: <us...@struts.apache.org>
> Sent: Tuesday, June 26, 2007 4:03 PM
> Subject: Form Upload throwing null pointer. cannot retrieve the file in 
> action class..HELP URGENT!!!
> 
> 
>>
>> Hi,
>>
>> I have a jsp from which i upload a file. this field is of Formfile type.
>>
>> jsp entry:
>>
>> <html:form method="post" enctype="multipart/form-data"
>> action="/pages/deploy-action.do" >
>> <td> <html:file name="deploymentForm"  property="theFile" /> </td>
>> <br>
>> <tr>
>> <td> <html:submit onclick="upload()" value="Upload the excel" >
>> </html:submit> </td>
>> </tr>
>> </html:form>
>>
>> I have not used bean:define in the jsp. when i use it,it throws cannot
>> assign null exception.
>>
>> in the struts config xml, entries are present for form - bean but not for
>> its property, i tried entering the property, it did not make a difference
>>
>> I am using the multiform/form-data enctype and also method=post.
>>
>> when i run the page and upload the file and invoke the action class i get
>> the following error.
>>
>> java.lang.NullPointerException
>>        at actions.DeployAction.execute(DeployAction.java:139)
>>        at
>> org.apache.struts.action.RequestProcessor.processActionPerform(Reques
>> tProcessor.java:419)
>>        at
>> org.apache.struts.action.RequestProcessor.process(RequestProcessor.ja
>> va:224)
>>        at
>> org.apache.struts.action.ActionServlet.process(ActionServlet.java:119
>> 6)
>>        at
>> org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
>>
>>
>> -- 
>> View this message in context: 
>> http://www.nabble.com/Form-Upload-throwing-null-pointer.-cannot-retrieve-the-file-in-action-class..HELP-URGENT%21%21%21-tf3983276.html#a11308662
>> Sent from the Struts - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Form-Upload-throwing-null-pointer.-cannot-retrieve-the-file-in-action-class..HELP-URGENT%21%21%21-tf3983276.html#a11309524
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Form Upload throwing null pointer. cannot retrieve the file in action class..HELP URGENT!!!

Posted by Nuwan Chandrasoma <my...@gmail.com>.
Hi,

try removing the .do from your action in the form and just put the action 
name what is in the struts-config.xml.

Thanks,

Nuwan


----- Original Message ----- 
From: "vbharath19" <bh...@gs.com>
To: <us...@struts.apache.org>
Sent: Tuesday, June 26, 2007 4:03 PM
Subject: Form Upload throwing null pointer. cannot retrieve the file in 
action class..HELP URGENT!!!


>
> Hi,
>
> I have a jsp from which i upload a file. this field is of Formfile type.
>
> jsp entry:
>
> <html:form method="post" enctype="multipart/form-data"
> action="/pages/deploy-action.do" >
> <td> <html:file name="deploymentForm"  property="theFile" /> </td>
> <br>
> <tr>
> <td> <html:submit onclick="upload()" value="Upload the excel" >
> </html:submit> </td>
> </tr>
> </html:form>
>
> I have not used bean:define in the jsp. when i use it,it throws cannot
> assign null exception.
>
> in the struts config xml, entries are present for form - bean but not for
> its property, i tried entering the property, it did not make a difference
>
> I am using the multiform/form-data enctype and also method=post.
>
> when i run the page and upload the file and invoke the action class i get
> the following error.
>
> java.lang.NullPointerException
>        at actions.DeployAction.execute(DeployAction.java:139)
>        at
> org.apache.struts.action.RequestProcessor.processActionPerform(Reques
> tProcessor.java:419)
>        at
> org.apache.struts.action.RequestProcessor.process(RequestProcessor.ja
> va:224)
>        at
> org.apache.struts.action.ActionServlet.process(ActionServlet.java:119
> 6)
>        at
> org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
>
>
> -- 
> View this message in context: 
> http://www.nabble.com/Form-Upload-throwing-null-pointer.-cannot-retrieve-the-file-in-action-class..HELP-URGENT%21%21%21-tf3983276.html#a11308662
> Sent from the Struts - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Form Upload throwing null pointer. cannot retrieve the file in action class..HELP URGENT!!!

Posted by vbharath19 <bh...@gs.com>.
it just sets a variable that i need to use in the action.


newton.dave wrote:
> 
> What does the "upload()" method in your
> <html:submit.../> do?
> 
> --- vbharath19 <bh...@gs.com> wrote:
> 
>> 
>> when i get the formfile using getthefile
>> 
>> 
>> 
>> newton.dave wrote:
>> > 
>> > --- vbharath19 <bh...@gs.com> wrote:
>> >> if (actioncalled!=null &&
>> > actioncalled.equals("upload")) {
>> >>     System.out.println("inside upload action");
>> >>     FormFile myFile =
>> deploymentForm.getTheFile();
>> >> }
>> > 
>> > We're getting there. Now, which line is throwing?
>> > 
>> > d.
>> > 
>> > 
>> > 
>> >        
>> >
>>
> ____________________________________________________________________________________
>> > Yahoo! oneSearch: Finally, mobile search 
>> > that gives answers, not web links. 
>> >
>>
> http://mobile.yahoo.com/mobileweb/onesearch?refer=1ONXIC
>> > 
>> >
>>
> ---------------------------------------------------------------------
>> > To unsubscribe, e-mail:
>> user-unsubscribe@struts.apache.org
>> > For additional commands, e-mail:
>> user-help@struts.apache.org
>> > 
>> > 
>> > 
>> 
>> -- 
>> View this message in context:
>>
> http://www.nabble.com/Form-Upload-throwing-null-pointer.-cannot-retrieve-the-file-in-action-class..HELP-URGENT%21%21%21-tf3983276.html#a11315299
>> Sent from the Struts - User mailing list archive at
>> Nabble.com.
>> 
>> 
>>
> ---------------------------------------------------------------------
>> To unsubscribe, e-mail:
>> user-unsubscribe@struts.apache.org
>> For additional commands, e-mail:
>> user-help@struts.apache.org
>> 
>> 
> 
> 
> 
>        
> ____________________________________________________________________________________
> Building a website is a piece of cake. Yahoo! Small Business gives you all
> the tools to get online.
> http://smallbusiness.yahoo.com/webhosting 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Form-Upload-throwing-null-pointer.-cannot-retrieve-the-file-in-action-class..HELP-URGENT%21%21%21-tf3983276.html#a11322777
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Form Upload throwing null pointer. cannot retrieve the file in action class..HELP URGENT!!!

Posted by Dave Newton <ne...@yahoo.com>.
What does the "upload()" method in your
<html:submit.../> do?

--- vbharath19 <bh...@gs.com> wrote:

> 
> when i get the formfile using getthefile
> 
> 
> 
> newton.dave wrote:
> > 
> > --- vbharath19 <bh...@gs.com> wrote:
> >> if (actioncalled!=null &&
> > actioncalled.equals("upload")) {
> >>     System.out.println("inside upload action");
> >>     FormFile myFile =
> deploymentForm.getTheFile();
> >> }
> > 
> > We're getting there. Now, which line is throwing?
> > 
> > d.
> > 
> > 
> > 
> >        
> >
>
____________________________________________________________________________________
> > Yahoo! oneSearch: Finally, mobile search 
> > that gives answers, not web links. 
> >
>
http://mobile.yahoo.com/mobileweb/onesearch?refer=1ONXIC
> > 
> >
>
---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> user-unsubscribe@struts.apache.org
> > For additional commands, e-mail:
> user-help@struts.apache.org
> > 
> > 
> > 
> 
> -- 
> View this message in context:
>
http://www.nabble.com/Form-Upload-throwing-null-pointer.-cannot-retrieve-the-file-in-action-class..HELP-URGENT%21%21%21-tf3983276.html#a11315299
> Sent from the Struts - User mailing list archive at
> Nabble.com.
> 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> user-unsubscribe@struts.apache.org
> For additional commands, e-mail:
> user-help@struts.apache.org
> 
> 



       
____________________________________________________________________________________
Building a website is a piece of cake. Yahoo! Small Business gives you all the tools to get online.
http://smallbusiness.yahoo.com/webhosting 

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Form Upload throwing null pointer. cannot retrieve the file in action class..HELP URGENT!!!

Posted by vbharath19 <bh...@gs.com>.
when i get the formfile using getthefile



newton.dave wrote:
> 
> --- vbharath19 <bh...@gs.com> wrote:
>> if (actioncalled!=null &&
> actioncalled.equals("upload")) {
>>     System.out.println("inside upload action");
>>     FormFile myFile = deploymentForm.getTheFile();
>> }
> 
> We're getting there. Now, which line is throwing?
> 
> d.
> 
> 
> 
>        
> ____________________________________________________________________________________
> Yahoo! oneSearch: Finally, mobile search 
> that gives answers, not web links. 
> http://mobile.yahoo.com/mobileweb/onesearch?refer=1ONXIC
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Form-Upload-throwing-null-pointer.-cannot-retrieve-the-file-in-action-class..HELP-URGENT%21%21%21-tf3983276.html#a11315299
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Form Upload throwing null pointer. cannot retrieve the file in action class..HELP URGENT!!!

Posted by Dave Newton <ne...@yahoo.com>.
--- vbharath19 <bh...@gs.com> wrote:
> if (actioncalled!=null &&
actioncalled.equals("upload")) {
>     System.out.println("inside upload action");
>     FormFile myFile = deploymentForm.getTheFile();
> }

We're getting there. Now, which line is throwing?

d.



       
____________________________________________________________________________________
Yahoo! oneSearch: Finally, mobile search 
that gives answers, not web links. 
http://mobile.yahoo.com/mobileweb/onesearch?refer=1ONXIC

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Form Upload throwing null pointer. cannot retrieve the file in action class..HELP URGENT!!!

Posted by vbharath19 <bh...@gs.com>.
sorry mate..this is the code that throws the exception

	if (actioncalled!=null && actioncalled.equals("upload"))
					{
				System.out.println("inside upload action");

				FormFile myFile = deploymentForm.getTheFile();
}



newton.dave wrote:
> 
> --- vbharath19 <bh...@gs.com> wrote:
>> when i run the page and upload the file and invoke
>> the action class i get the following error.
>> 
>> java.lang.NullPointerException
>>         at
>> actions.DeployAction.execute(DeployAction.java:139)
> 
> Why wouldn't you include the code that's throwing the
> exception?!
> 
> d.
> 
> 
> 
>  
> ____________________________________________________________________________________
> It's here! Your new message!  
> Get new email alerts with the free Yahoo! Toolbar.
> http://tools.search.yahoo.com/toolbar/features/mail/
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Form-Upload-throwing-null-pointer.-cannot-retrieve-the-file-in-action-class..HELP-URGENT%21%21%21-tf3983276.html#a11309749
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Form Upload throwing null pointer. cannot retrieve the file in action class..HELP URGENT!!!

Posted by Dave Newton <ne...@yahoo.com>.
--- vbharath19 <bh...@gs.com> wrote:
> when i run the page and upload the file and invoke
> the action class i get the following error.
> 
> java.lang.NullPointerException
>         at
> actions.DeployAction.execute(DeployAction.java:139)

Why wouldn't you include the code that's throwing the
exception?!

d.



 
____________________________________________________________________________________
It's here! Your new message!  
Get new email alerts with the free Yahoo! Toolbar.
http://tools.search.yahoo.com/toolbar/features/mail/

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org