• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1719
  • Last Modified:

how to specify relative path in jsp

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
vamshipajjuri
Asked:
vamshipajjuri
  • 2
1 Solution
 
knightEknightCommented:
Try this:

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

or this:

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

0
 
COBOLdinosaurCommented:
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
 
COBOLdinosaurCommented:
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now