• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

open a file on a button click event in a JSP

 
samriddha kelkar
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 6663
5
Firefox Browser Linux MyEclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
samriddha kelkar
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 6663
5
Firefox Browser Linux MyEclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic