This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes JSP and the fly likes File Upload JSP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "File Upload JSP" Watch "File Upload JSP" New topic
Author

File Upload JSP

Rohit Malhotra
Greenhorn

Joined: Jan 29, 2006
Posts: 21
Hi,

I have written a JSP for File Upload which has a form element
<"FORM ENCTYPE="multipart/form-data">
<input type="submit" name="option" value="upload">
<input type="submit" name="option" value="check-in">
</form>
the problem is now. i want to check which button is clicked. by request.getPArameter("option"); however. it does not return any value since the enctp is mulipart/form. Can anyone please let me know how can i check which button is clickd?
Reggards,
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60046
    
  65

How are you parsing the multi-part request? With your own code, or a 3rd-party package?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Rohit Malhotra
Greenhorn

Joined: Jan 29, 2006
Posts: 21
I am using a third party tool typically FileUpload jar from apache.
Stefan Evans
Bartender

Joined: Jul 06, 2005
Posts: 1016
The fileUpload component has a guide here that demonstrates how to retrieve the standard request parameters.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60046
    
  65

The documentation of your upload package should tell you how to obtain the non-file parameters. If your package doesn't let you do that, try a different one.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60046
    
  65

Originally posted by srilatha reddy:
onclick event of button write code to set the value in request/session object


And how exactly do you propose he do that?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60046
    
  65

Originally posted by srilatha reddy:
within jsp scriplet write
request.setAttribute("todo","upload");

in onclick event



That would be pointless. The onclick event is fired on the client as a Javscript event. Any scriptlet "embedded" in it would have been executed on the server before the page was even sent to the browser.
[ March 01, 2006: Message edited by: Bear Bibeault ]
 
Consider Paul's rocket mass heater.
 
subject: File Upload JSP
 
Similar Threads
Uploading images with jsp
I have this strange display problem
Is there any way to do check how many files the user have uploaded?
How to Upload the Client File To The Server
sending a servlet parameters