This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JSP and the fly likes open a file on a button click event in a JSP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "open a file on a button click event in a JSP" Watch "open a file on a button click event in a JSP" New topic
Author

open a file on a button click event in a JSP

samriddha kelkar
Greenhorn

Joined: Jan 21, 2010
Posts: 2
hi i am new to JAVA. What i want to do is i have a JSP page and in that =i have a click button. On the click event of the button i want to open a file which will be stored at a particular path. This file path will be stored in the database and i want to get that path at run time on the button click event , and show it in a new window.Can anybody please let me know how to do it . code sniipets will be always welcome

Thanks And Regards
symtojava
Deepak Bala
Bartender

Joined: Feb 24, 2006
Posts: 6661
    
    5

1. Click on the button
2. Redirect to a servlet
3. Get the file information from the database
4. Attach the data to one of the scopes (request / session etc)
5. Display the data in a JSP


SCJP 6 articles - SCJP 5/6 mock exams - More SCJP Mocks
samriddha kelkar
Greenhorn

Joined: Jan 21, 2010
Posts: 2
Hi Deepak thnx for your reply. The file path which i am redirecting to on the button click event is not in the app context. So when i click on button, container tries to find the file relative to application context. For example i am storing xml file in /jboss_home/server/default/deploy/Test.war folder. And my application context is http://localhost:8080/testApp/ . So when i try to redirect to the file it searches in http://localhost:8080/testApp/"file path". How can i solve this problem.


Thanks Regards
symtojava
Deepak Bala
Bartender

Joined: Feb 24, 2006
Posts: 6661
    
    5

You cannot serve the file unless the file resides inside the context. If you do want to serve a file outside the context you must read and stream the file to the user
 
Consider Paul's rocket mass heater.
 
subject: open a file on a button click event in a JSP
 
Similar Threads
need event occure after click on dialog button
File download and request Forward
opening new frame
need event occure after click on dialog button
Problem with JFileChooser