Link to home
Start Free TrialLog in
Avatar of vamshipajjuri
vamshipajjuri

asked on

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
ASKER CERTIFIED SOLUTION
Avatar of knightEknight
knightEknight
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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:
https://www.experts-exchange.com/help/closing.jsp


Cd&

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&