Wher to keep files to make it accessible in apache tomcat?

Report
Question

Please briefly explain why you feel this question should be reported .

Report Cancel

I have a file named index.jsp that contains a form, form action is a .java file named getAttr.java . Inside getAttr.java servlet I am writing code that will download a .jar file located in same directory as WEB-INF.

getJar.java code:

protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    response.setContentType("application/jar");
    ServletContext context=getServletContext();
    InputStream inputStream=context.getResourceAsStream("eee.jar");
    int read=0;
    byte bytes[]=new byte[1024];
    OutputStream outputStream=response.getOutputStream();
    while((read=inputStream.read(bytes))!=-1){
        outputStream.write(bytes,0,read);
    }
    outputStream.flush();
    RequestDispatcher dispatcher=request.getRequestDispatcher("getJar.jsp");
    dispatcher.forward(request, response);
    outputStream.close();
}
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    // TODO Auto-generated method stub
    doGet(request, response);
}

getJar.jsp code:

<!-- necessary html code here  !>
<body>
<%
// contains no code. 
//I don't know what to write here
%>
</body>
<!-- necessary html code here  !>

I am coding J2EE in eclipse neon. My directory structure

Now my problem is:
User clicks a button in index.jsp which sends him to getAttr.java servlet.
getAttr servlet shows this error:

enter image description here

perhaps eee.jar is not accessible. Where to keep this .jar file?
Ask me if more information is needed.

0
0 Answer 10 views 0