• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to pass the path of the file to StreamSource class

 
Ravi Kiran Va
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Mine is a web application .

I am using JAXP technology to transform a static xml file data into a HTML file .

Here i am struck up , I am allowing user to input the xml file and the xsl file with the help of

Now i need to pass these file xml/xsl paths into the StreamSource class .

The constructor for the StreamSource class is

Please tell me how can i do this ??

For instance if its a Standalone application i would have allowed user to input the xml file through command prompt like this :





Please tell me how can i achieve this in a web Based Application . How can i pass the file path ??

Thank you for reading .
 
Chinna Eranna
Ranch Hand
Posts: 174
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
StreamSource class has different constructors..

When you upload a file, you will get a InputStream in your controller (either Servlet/Action classs) and You should make use of StreamSource(InputStream)..
 
Ravi Kiran Va
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey Thank you.

I am out of Ideas here .


Assume that this is inside my jsp file

<input type="file"/>


Please tell me how can i get information about this file so that i can use getAbsolutePath on it ??

 
Paul Clapham
Sheriff
Posts: 21554
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can't. The <input file=""> element in HTML exists in the browser on the client. The browser user will select a file from the client computer and the contents of that file will be sent to the server as part of the request. You must use those contents. Trying to have the server access the file from the client's computer via its name doesn't work.
 
Deepak Bala
Bartender
Posts: 6663
5
Firefox Browser Linux MyEclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are going to upload more than one file, you will have to use a multipart form. You can use the commons upload API and pass the input stream to StreamSource
 
Chinna Eranna
Ranch Hand
Posts: 174
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
does you application uses any framework ?
 
Ravi Kiran Va
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much I will see this concept.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic