Sheldon R. Sheldon R. - 1 year ago 63
Java Question

ServletException (JNLP JSP not found)

I'm developing a JWS application as an applet replacement. So far I've been able to launch my app from its parent application via a link in an HTML page to static JNLP. But my app really needs to be launched by dynamic JNLP since the argument values will be different with each execution. So I decided to extend the JnlpDownloadServlet in the manner shown [here][1]. My download servlet is called

, which is mapped to a URL pattern
and which references a JSP called
, which currently contains some static JNLP, in the overriden method

protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
HttpServletRequest request = (HttpServletRequest) req;
request.getRequestDispatcher("/myJnlp.jsp").include(request, resp);

When I try to invoke my download servlet, I get the following error:

javax.servlet.ServletException: File "/myJnlp.jsp" not found

I placed
in the directory
which is the directory that contains the other JSPs used by the parent application. Did I put the JNLP page in the wrong location or did I specify it incorrectly in my servlet code?

Answer Source

I solved this by creating a subdirectory called myJWSApp, then I placed the JNLP JSP in that directory then referenced it as

request.getRequestDispatcher("myJWSApp/myJnlp.jsp").include(request, resp);

Thanks to @rickz whose comment pointed me in the right direction...