5 Replies - 424 Views - Last Post: 17 July 2017 - 05:30 AM

#1 kavithav  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 28
  • Joined: 02-April 17

How to pass the file path dynamically from jsp to servelet dynamically

Posted 16 July 2017 - 11:56 PM

I am using a file uploader to choose the file and i need to pass that file path to my servlet dynamically instead of giving the file path statically how can i do this.Below is my jsp code

<label for="fileName">Select File: </label>
<input id="fileName" type="file" name="fileName" size="30"/> <br/>
<input type="submit" value="Upload"/>

Below is my servlet code where i am passing the path statically how can i pass dynamically

File file = new File("C:Desktop\\test.ods");
Upload objODSReader = new Upload();
objODSReader.readODS(file);

Is This A Good Question/Topic? 0
  • +

Replies To: How to pass the file path dynamically from jsp to servelet dynamically

#2 g00se  Icon User is online

  • D.I.C Lover
  • member icon

Reputation: 3464
  • View blog
  • Posts: 15,676
  • Joined: 20-September 08

Re: How to pass the file path dynamically from jsp to servelet dynamically

Posted 17 July 2017 - 01:13 AM

The value of the file name would be the value of the form element with id 'fileName'.
Was This Post Helpful? 0
  • +
  • -

#3 kavithav  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 28
  • Joined: 02-April 17

Re: How to pass the file path dynamically from jsp to servelet dynamically

Posted 17 July 2017 - 01:19 AM

i had passed in that way only but it is becoming null and going to catch block can you please show me how to do that as ia m new to this
Was This Post Helpful? 0
  • +
  • -

#4 kavithav  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 28
  • Joined: 02-April 17

Re: How to pass the file path dynamically from jsp to servelet dynamically

Posted 17 July 2017 - 01:28 AM

i had passed in this way

File file = new File("fileName");

but it is going into catch block
Was This Post Helpful? 0
  • +
  • -

#5 g00se  Icon User is online

  • D.I.C Lover
  • member icon

Reputation: 3464
  • View blog
  • Posts: 15,676
  • Joined: 20-September 08

Re: How to pass the file path dynamically from jsp to servelet dynamically

Posted 17 July 2017 - 01:38 AM

You need to learn the basics of how servlets work. This is not the place for step 1 tutorials
Was This Post Helpful? 0
  • +
  • -

#6 blackcompe  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1159
  • View blog
  • Posts: 2,547
  • Joined: 05-May 05

Re: How to pass the file path dynamically from jsp to servelet dynamically

Posted 17 July 2017 - 05:30 AM

Kavithav, check out the HttpServletRequest class and/or relevant examples.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1