This week's book giveaway is in the Agile and other Processes forum. We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line! See this thread for details.
Dear everyone, Iam trying to upload files to server using servlets. iam using apache fileupload to upload the files . But iam facing problem when using List in the program to get the list of uploaded files.
Thank You for the consideration, i have sorted out the problem now i can upload files to server.
Now can you help me by giving any links to learn "HOW TO DOWNLOAD FILES FROM THE SERVER AND DISPLAY ON THE CLIENT MACHINE" or please give me some information on how to do this.
Thank you, Jagdish K
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35237
7
posted
0
What do you mean by "download"? The easiest way is to put a link to the files on a web page, and users can just click on it. If you're talking about something else, post the details of what you're trying to do.
How you serve up files depends on where they are. We have an example application in our CodeBarn that streams image files that are stored under the WEB-INF directory to the browser.
If the files are located within your application's directory structure but not under WEB-INF, a simple hyperlink should be sufficient. If you're storing the files outside of the application's directory structure, you would want to do something similar to what's done in our codebarn example but use java.io.File to read the file off the server's disk instead of using context.getResourceAsStream.
Iam new to java programming. Thanks for your courtesy.
I had reffered your link. Thank you. My problem is positioning the images at the right places in the html. In the example given by you the images has been stored under WEB-INF of the project. In my module the images are storerd in the root directory of the Tomcat server ie. in local system: C:\Program Files\Apache Software Foundation\Apache Tomcat 6.0.14\images\one.jpg I want to access the image over the network and display it in appropriate table cell of my html when the client access the page.
What should i do to get the relative path of the above mentioned file and display the image.
Java Servlet containers support the concept of web applications. Each application has its own directory structure. In Tomcat, by default these application directories go under tomcat/webapps. If you keep your images in the application to which they belong, all you'll need to do to view them in a web pages is create a plain old <img ../> tag with a relative link to the images. See: http://faq.javaranch.com/java/ResourceUrls to learn how to create proper context relative links.
If you must store your images outside of the web application (and I still wouldn't store them inside the Tomcat directory structure), you'll need to write a servlet, similar to the one in SimpleStream, that reads the file from disk (using java.io.FileReader) and streams it to the client. This is, of course, much more work than linking to a file inside the application's directory structure.
jagdish waran
Greenhorn
Joined: Mar 31, 2008
Posts: 6
posted
0
[ UD: Please start a new thread for completely unrelated questions. We like to keep each discussion thread focused on a single topic. What's more, you've already posted that question in a different forum. ] [ April 08, 2008: Message edited by: Ulf Dittmer ]
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.