|
The issue with the <link> tag in your HTML is just a simple HTML/HTTP issue. The browser is going to request the resource relative to the URL of the document it is displaying. It doesn't know where the JSP itself came from (or even that it was a JSP). You can control this by using the <base> tag in your HTML. Then the browser will use the href specified in that tag as the base location for any relative links on the page. To "'Websphere Development Studio Client for iSeries'" <wdsci-l@xxxxxxxxxxxx> cc bcc Subject RE: [WDSCI-L] CSS Links flagged as errors. "Joe Pluta" <joepluta@xxxxxxxxxxxxxxxxx> Sent by: wdsci-l-bounces@xxxxxxxxxxxx 01/02/2004 03:55 PM CST <HR><font size=-1>Please respond to Websphere Development Studio Client for iSeries <wdsci-l@xxxxxxxxxxxx></font><HR> <font size=-1></font> > 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 _______________________________________________ This is the Websphere Development Studio Client for iSeries (WDSCI-L) mailing list To post a message email: WDSCI-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options, visit: http://lists.midrange.com/mailman/listinfo/wdsci-l or email: WDSCI-L-request@xxxxxxxxxxxx Before posting, please take a moment to review the archives at http://archive.midrange.com/wdsci-l.
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 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.