?
Solved

how to specify relative path in jsp

Posted on 2003-02-21
3
Medium Priority
?
1,717 Views
Last Modified: 2008-01-16
hi all,

i want the client to download a file from server side

here is my directiory structure

                  WebRegistration
                          /        \
                         /          \
                        /            \
                      jsp           WEB-INF
                      /              \
                     /                \
                    /                  \
               localreg             classes
                                      /  
                                     /
                                 registration  
                                  /
                                 /
                              files

my jsp's are in left "localreg" folder  and my java programs are in "registration" folder and the file which client should download is in "files" folder

here is the jsp which i am using to make client download the file

String filename ="download.ash";(this is in "files"folder)
String filepath =
response.setContentType("APPLICATION/OCTET-STREAM");
response.setHeader("Content-Disposition","attachment; filename=\"" + filename + "\"");
out.flush();
java.io.FileInputStream fileInputStream =new java.io.FileInputStream(filepath+"/"+filename);
int i=0;
while ((i=fileInputStream.read())!= -1)
{
     out.write(i);
}
fileInputStream.close();
out.flush();
out.close();

what i want to know is how should i write "filepath"(in the porgram) relatively.

thanks in advance

regards,
vamshi
0
Comment
Question by:vamshipajjuri
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 33

Accepted Solution

by:
knightEknight earned 80 total points
ID: 7995571
Try this:

String filepath = "../../WEB-INF/classes/registration/files";

or this:

String filepath = "..\\..\\WEB-INF\\classes\\registration\\files";

0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 8820391
This question has been classified abandoned. I will make a recommendation to the
moderators on its resolution in a week or two. I appreciate any comments
that would help me to make a recommendation.

<note>
Unless it is clear to me that the question has been answered I will recommend delete.  It is possible that a Grade less than A will be given if no expert makes a case for an A grade. It is assumed that any participant not responding to this request is no longer interested in its final disposition.
</note>

If the user does not know how to close the question, the options are here:
http://www.experts-exchange.com/help/closing.jsp


Cd&

0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 8963751
It is time to clean this abandoned question up.

I am putting it on a clean up list for CS.

<recommendation>
points to knihgtEknight

</recommendation>

If anyone participating in the Q disagrees with the recommendation,
please leave a comment for the mods.

Cd&

0

Featured Post

Are You Using the Best Web Development Editor?

The worlds of web hosting and web development are constantly evolving. Every year we see design trends change, coding standards adapt and new frameworks/CMS created. With such a quick pace of change it’s easy to get lost trying to keep up.

See if your editor made the list.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
This article discusses how to create an extensible mechanism for linked drop downs.
In this tutorial viewers will learn how add a scalable full-width header using CSS3. Create a new HTML document with an internal stylesheet. Set a tiled background.:  Create a new div and name it Header. Position it with position:absolute at the top…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question