|
> From: Mark Phippard > > JSP/Java and HTML have slightly different relative paths because of how > they handle the context root. Actually, Mark, it's a little more involved than that. As it turns out, the problem occurs when you include a JSP via the RequestDispatcher.include() method. In WAS5, if you get your request dispatcher from the servlet context and then include a JSP, the context base is actually /servlet, and it uses this as the base when resolving HTML requests such as CSS links, even though the actual JSP may be from a completely different context. In WAS35, it seems that the dispatcher used the context of the JSP as its base, not the context of the servlet. The WAS35 technique is much nicer, since it allows you to create your applications without worrying about the context of the servlet. This is confusing in words. An example: public class Includer extends HttpServlet implements Servlet { public void doGet (HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { getServletContext(). getRequestDispatcher("/app1/v1/test1.jsp"). forward(req, resp); } } The JSP, /app1/v1/test1.jsp: <HTML> <HEAD> <TITLE>test1.jsp</TITLE> <LINK rel="stylesheet" href="../include/styles/blue.css" type="text/css"> </HEAD> <BODY> <P>Snippet Below</P> <%@include file="../../include/snippets/snip1.jsp"%> <P>Snippet Above</P> </BODY> </HTML> Both the snippets folder and the styles folder exist in the same include folder. But to access the snippet, I need to use TWO "../" references, while the CSS requires only one. If, however, I try to run the JSP directly without the use of the servlet, it will not pick up the CSS... UNLESS I include TWO "../" references. Very annoying. > Finally, in some cases I think the validators are just wrong, and if it > works at runtime all you can do is ignore the errors in your Tasks list. This is the reason I wrote the post. I was asking if anyone else ran up against the validators being wrong. Joe
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.