Re: CSS not being used when a Servlet is involved
Christopher Schultz-2 wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Robert, Robbert wrote: Christopher Schultz-2 wrote: Whether or not you use struts, I highly recommend that you avoid tricks like calling a servlet from a JSP in order to execute your business logic. If you have a waterfall-style logical flow (i.e. execute servlet first, then JSP), it's only natural to have the flow actually do that. It's okay if you application isn't 100% pull-based ;) -chris It seemed like a good way of doing things at the time, since the Servlet's output is not needed for the page itself. :p But I am doing more things than necessary, yeah. Aah, I see that you're saying. Often, servlets emit no output. I would say that /almost all/ servlets emit no output, but that they are generally used to set up the request so that control can be passed to an output-generating mechanism (JSP, Velocity, whatever). This is the natural way that pretty much everybody does servlet programming. The best reason to switch is that you are having problems with your awkward setup, eh? ;) Good luck, - -chris Well, switching things around a bit worked. After reinstalling Tomcat Apache and ant completely and starting from scratch, I managed to get it working. Before a page is called, it invokes the StatistiekServlet and then does a requestDispatcher to the page that the user wants to see (e.g.: The user requests /Index, the StatistiekServlet registers the necessary hits and forwards to /pages/Index.jsp). At least I now get images and everything is being processed correctly. There's another problem, but I'll get to that in another thread. Thanks for your outstanding help! I owe you a beer. ;) Regards, Robbert -- View this message in context: http://www.nabble.com/CSS-not-being-used-when-a-Servlet-is-involved-tf2521410.html#a7507314 Sent from the Tomcat - User mailing list archive at Nabble.com. - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: CSS not being used when a Servlet is involved
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Robert, Robbert wrote: Christopher Schultz-2 wrote: Whether or not you use struts, I highly recommend that you avoid tricks like calling a servlet from a JSP in order to execute your business logic. If you have a waterfall-style logical flow (i.e. execute servlet first, then JSP), it's only natural to have the flow actually do that. It's okay if you application isn't 100% pull-based ;) -chris It seemed like a good way of doing things at the time, since the Servlet's output is not needed for the page itself. :p But I am doing more things than necessary, yeah. Aah, I see that you're saying. Often, servlets emit no output. I would say that /almost all/ servlets emit no output, but that they are generally used to set up the request so that control can be passed to an output-generating mechanism (JSP, Velocity, whatever). This is the natural way that pretty much everybody does servlet programming. The best reason to switch is that you are having problems with your awkward setup, eh? ;) Good luck, - -chris -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.5 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFFXG/29CaO5/Lv0PARAshOAKCGunDTgL5egrEieSYKwS7Hi48F/ACcCsh4 TeB3BczhDR/32arMc1MjpwA= =HsIr -END PGP SIGNATURE- - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: CSS not being used when a Servlet is involved
Apologies for the late reply. I've had some more pressing to attend to. Christopher Schultz-2 wrote: Robbert, Christopher Schultz-2 wrote: You have your process turned upside down, here. Why is the process turned upside down, exactly? Or rather, is there any benefit in mapping /index to a Servlet and then forwarding to a JSP instead of going to JSP pages which invoke my Servlet? This probably boils down to the following question: When do you use a JSP and when do you use a Servlet? Well, that's a somewhat philosophical and often religious argument. I think that one ought to use JSPs for quick-and-dirty hacked logic, /or/ for display purposes only. Your real work ought to be done in servlets. I find the error handling more straightforward and less messy than in JSPs (although a JSP does get translated into a servlet before execution, so really they are exactly the same thing). I have to agree totally with that. It's the more logical thing to do. Christopher Schultz-2 wrote: At any rate, what you are trying to do is: 1) Perform some logic in your servlet. 2) Emit some output to the client. Since you want to do those 2 things, in that order, why invoke #2 first, which calls-back to #1, and then emits the output? It's far more natural to invoke the servlet and then have it forward to the JSP. Note that this is an internal forward, so the browser has no idea that control has been transferred from the servlet to the JSP. Of course, you could also use an HTTP FORWARD if that's what you really wanted to do. True... I hadn't thought it about it like that. Still, no one knows that the servlet is being executed because it happens while the page is being loaded. If I do it that way (let my Servlet catch all the requests, do some logic and forward to the JSP), then I won't have any problems with CSS or images, right? Since the Servlet is no longer invoked via the JSP, it shouldn't be a problem. Because right now, I can get the CSS to work, but the images aren't being shown for some reason or another (even though the links in the CSS file are correct). Christopher Schultz-2 wrote: Struts sounds like a good framework. I'm not too experienced with those but I take it that won't be hard to use. It's just how we were learned to code. So it never seemed to me as if the process was reversed. Whether or not you use struts, I highly recommend that you avoid tricks like calling a servlet from a JSP in order to execute your business logic. If you have a waterfall-style logical flow (i.e. execute servlet first, then JSP), it's only natural to have the flow actually do that. It's okay if you application isn't 100% pull-based ;) -chris It seemed like a good way of doing things at the time, since the Servlet's output is not needed for the page itself. :p But I am doing more things than necessary, yeah. -- View this message in context: http://www.nabble.com/CSS-not-being-used-when-a-Servlet-is-involved-tf2521410.html#a7369839 Sent from the Tomcat - User mailing list archive at Nabble.com. - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: CSS not being used when a Servlet is involved
Caldarale, Charles R wrote: From: Robbert [mailto:[EMAIL PROTECTED] Subject: RE: CSS not being used when a Servlet is involved Hm, alright. Should all else fail, is it possible to let a Servlet handle the CSS? Some servlet must handle everything; static content (including .css files) is normally handled by Tomcat's DefaultServlet. Ah, and because I called a different Servlet in my JSP, any and all requests went to that Servlet and since that Servlet couldn't handle them, it just showed text. Caldarale, Charles R wrote: I have four JSP pages (index, profile, statistics and gallery) that must invoke the StatistiekServlet. The page is simply a normal, static HTML page that calls the Servlet. By definition, a JSP page isn't static, but that's probably irrelevant. Yeah, I actually meant that it outputs static HTML, mostly. Caldarale, Charles R wrote: That works! Thank you very much! If you have not redefined the servlet-name default within your webapp, you can simplify what I gave you before. Leave out the servlet declaration for tcdefault, and change the *.css mapping to use just default. As someone else pointed out, default is already declared in conf/web.xml to use the proper servlet class, and conf/web.xml is automatically included in for every webapp. Ah, I see. It's all starting to make sense now. I'm so glad I posted this here 'cause no one else knew an answer. It does sound like a neatier solution. Caldarale, Charles R wrote: Are there any drawbacks to this method? None that I can think of. - Chuck Good. I owe you one. Thanks! Robbert -- View this message in context: http://www.nabble.com/CSS-not-being-used-when-a-Servlet-is-involved-tf2521410.html#a7060454 Sent from the Tomcat - User mailing list archive at Nabble.com. - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: CSS not being used when a Servlet is involved
Christopher Schultz-2 wrote: Robbert, Hm, alright. Should all else fail, is it possible to let a Servlet handle the CSS? You don't really want to do this. No, especially since it's not needed anymore. Christopher Schultz-2 wrote: I have four JSP pages (index, profile, statistics and gallery) that must invoke the StatistiekServlet. The page is simply a normal, static HTML page that calls the Servlet. Then the Servlet catches certain HTTP Headers and query strings and does stuff depending on the values. When the Servlet's finished, the JSP continues spitting out HTML code. And if I do that, it says Resource not available: /StatistiekServlet for whatever reason. Since you mentioned that you aren't very familiar with servlets, I'll go ahead and say the following. Sorry if it sounds patronizing. It's alright. I'm here to learn. Christopher Schultz-2 wrote: You have your process turned upside down, here. You are using a JSP as the target of the URL, then invoking a servlet from there to do your dirty work, and then going back. This is the wrong way to do things. What you really want to do is map /index to your StatistiekServlet, do whatever you need to do, and then do a forward (using the RequestDispatcher) to your JSP in order to generate the outgoing content. Why is the process turned upside down, exactly? Or rather, is there any benefit in mapping /index to a Servlet and then forwarding to a JSP instead of going to JSP pages which invoke my Servlet? This probably boils down to the following question: When do you use a JSP and when do you use a Servlet? Christopher Schultz-2 wrote: I'm guessing that you have this separate servlet for several reasons: 1. You have shared code to execute. 2. Someone (correctly) told you that JSPs with tons of logic and Java code are ... icky? 3. You weren't sure how to re-use your servlet code and not have to inspect the URL to figure out to which JSP you should forward afterward. If you want to use shared code in a JSP (#1), you can simply put it in a utility class/method that takes the appropriate methods. You don't have to use the servlet mechanism and actually use a servlet to do this stuff. Number 1 is correct and 3 is partially correct. The fourth, invisible, option you didn't mention (and which you didn't know) is as follows: The assignment requires the use of a StatistiekServlet which was a Servlet acting behind the scenes. The way I did it seemed the easiest way since JSP's can contain snippets of Java code: Kinda like how you can embed snippets of PHP in a PHP file. Christopher Schultz-2 wrote: The easiest way I can think of to invert your process (i.e. start with the servlet, /then/ forward to the JSP based upon the URL being used) is to use an application framework that helps you by mapping URLs to code and then lets you define forwards for that URL mapping. Struts is such a framework. You can set up mappings like this: action path=/index type=your.shared.code.class forward name=success path=/index.jsp / /action action path=/profile type=your.shared.code.class forward name=success path=/profile.jsp / /action action path=/statistics type=your.shared.code.class forward name=success path=/statistics.jsp / /action action path=/gallery type=your.shared.code.class forward name=success path=/gallery.jsp / /action Note that the code invoked is the same every time; only the success page changes. Your servlet code will have to turn into an Action (no big deal) and have a bit of code at the end to tell Struts to use the success forward (also not a big deal). But, if you really want to have a nicely separated MVC application, Struts can help tremendously. It looks like you have tried to take some of these steps yourself, but have gotten confused somewhere along the way -- ending up with your JSPs invoking your servlet, which feels /very/ weird to me. -chris Struts sounds like a good framework. I'm not too experienced with those but I take it that won't be hard to use. It's just how we were learned to code. So it never seemed to me as if the process was reversed. -- View this message in context: http://www.nabble.com/CSS-not-being-used-when-a-Servlet-is-involved-tf2521410.html#a7060632 Sent from the Tomcat - User mailing list archive at Nabble.com. - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: CSS not being used when a Servlet is involved
Robbert, Christopher Schultz-2 wrote: You have your process turned upside down, here. Why is the process turned upside down, exactly? Or rather, is there any benefit in mapping /index to a Servlet and then forwarding to a JSP instead of going to JSP pages which invoke my Servlet? This probably boils down to the following question: When do you use a JSP and when do you use a Servlet? Well, that's a somewhat philosophical and often religious argument. I think that one ought to use JSPs for quick-and-dirty hacked logic, /or/ for display purposes only. Your real work ought to be done in servlets. I find the error handling more straightforward and less messy than in JSPs (although a JSP does get translated into a servlet before execution, so really they are exactly the same thing). At any rate, what you are trying to do is: 1) Perform some logic in your servlet. 2) Emit some output to the client. Since you want to do those 2 things, in that order, why invoke #2 first, which calls-back to #1, and then emits the output? It's far more natural to invoke the servlet and then have it forward to the JSP. Note that this is an internal forward, so the browser has no idea that control has been transferred from the servlet to the JSP. Of course, you could also use an HTTP FORWARD if that's what you really wanted to do. Struts sounds like a good framework. I'm not too experienced with those but I take it that won't be hard to use. It's just how we were learned to code. So it never seemed to me as if the process was reversed. Whether or not you use struts, I highly recommend that you avoid tricks like calling a servlet from a JSP in order to execute your business logic. If you have a waterfall-style logical flow (i.e. execute servlet first, then JSP), it's only natural to have the flow actually do that. It's okay if you application isn't 100% pull-based ;) -chris signature.asc Description: OpenPGP digital signature
RE: CSS not being used when a Servlet is involved
Caldarale, Charles R wrote: From: Robbert [mailto:[EMAIL PROTECTED] Subject: RE: CSS not being used when a Servlet is involved Combining that with what you just said, I assume that you're basically saying that my servlet tries to handle the link tag that contains the URL to my CSS, but fails miserably in the process? Yes, that's what I think is going on. Hm, alright. Should all else fail, is it possible to let a Servlet handle the CSS? Caldarale, Charles R wrote: If so, then how do I change my web.xml file in such a manner that the Servlet leaves the CSS alone? I don't know how your app is architected, so I don't know if you want nearly all URI references to go to the StatistiekServlet, or just specific ones. If it's just specific, use those on the url-pattern, rather than just a slash. I have four JSP pages (index, profile, statistics and gallery) that must invoke the StatistiekServlet. The page is simply a normal, static HTML page that calls the Servlet. Then the Servlet catches certain HTTP Headers and query strings and does stuff depending on the values. When the Servlet's finished, the JSP continues spitting out HTML code. And if I do that, it says Resource not available: /StatistiekServlet for whatever reason. Caldarale, Charles R wrote: If StatistiekServlet should process everything but the .css files, try putting this in your web.xml: servlet servlet-nametcdefault/servlet-name servlet-classorg.apache.catalina.servlets.DefaultServlet/servlet-clas s /servlet servlet-mapping servlet-nametcdefault/servlet-name url-pattern*.css/url-pattern /servlet-mapping This would be in addition to what you already have. - Chuck P.S. This thread is converging with another one from today... That works! Thank you very much! Are there any drawbacks to this method? -- View this message in context: http://www.nabble.com/CSS-not-being-used-when-a-Servlet-is-involved-tf2521410.html#a7047719 Sent from the Tomcat - User mailing list archive at Nabble.com. - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: CSS not being used when a Servlet is involved
Robbert, Hm, alright. Should all else fail, is it possible to let a Servlet handle the CSS? You don't really want to do this. I have four JSP pages (index, profile, statistics and gallery) that must invoke the StatistiekServlet. The page is simply a normal, static HTML page that calls the Servlet. Then the Servlet catches certain HTTP Headers and query strings and does stuff depending on the values. When the Servlet's finished, the JSP continues spitting out HTML code. And if I do that, it says Resource not available: /StatistiekServlet for whatever reason. Since you mentioned that you aren't very familiar with servlets, I'll go ahead and say the following. Sorry if it sounds patronizing. You have your process turned upside down, here. You are using a JSP as the target of the URL, then invoking a servlet from there to do your dirty work, and then going back. This is the wrong way to do things. What you really want to do is map /index to your StatistiekServlet, do whatever you need to do, and then do a forward (using the RequestDispatcher) to your JSP in order to generate the outgoing content. I'm guessing that you have this separate servlet for several reasons: 1. You have shared code to execute. 2. Someone (correctly) told you that JSPs with tons of logic and Java code are ... icky? 3. You weren't sure how to re-use your servlet code and not have to inspect the URL to figure out to which JSP you should forward afterward. If you want to use shared code in a JSP (#1), you can simply put it in a utility class/method that takes the appropriate methods. You don't have to use the servlet mechanism and actually use a servlet to do this stuff. The easiest way I can think of to invert your process (i.e. start with the servlet, /then/ forward to the JSP based upon the URL being used) is to use an application framework that helps you by mapping URLs to code and then lets you define forwards for that URL mapping. Struts is such a framework. You can set up mappings like this: action path=/index type=your.shared.code.class forward name=success path=/index.jsp / /action action path=/profile type=your.shared.code.class forward name=success path=/profile.jsp / /action action path=/statistics type=your.shared.code.class forward name=success path=/statistics.jsp / /action action path=/gallery type=your.shared.code.class forward name=success path=/gallery.jsp / /action Note that the code invoked is the same every time; only the success page changes. Your servlet code will have to turn into an Action (no big deal) and have a bit of code at the end to tell Struts to use the success forward (also not a big deal). But, if you really want to have a nicely separated MVC application, Struts can help tremendously. It looks like you have tried to take some of these steps yourself, but have gotten confused somewhere along the way -- ending up with your JSPs invoking your servlet, which feels /very/ weird to me. -chris signature.asc Description: OpenPGP digital signature
RE: CSS not being used when a Servlet is involved
From: Robbert [mailto:[EMAIL PROTECTED] Subject: RE: CSS not being used when a Servlet is involved Hm, alright. Should all else fail, is it possible to let a Servlet handle the CSS? Some servlet must handle everything; static content (including .css files) is normally handled by Tomcat's DefaultServlet. I have four JSP pages (index, profile, statistics and gallery) that must invoke the StatistiekServlet. The page is simply a normal, static HTML page that calls the Servlet. By definition, a JSP page isn't static, but that's probably irrelevant. That works! Thank you very much! If you have not redefined the servlet-name default within your webapp, you can simplify what I gave you before. Leave out the servlet declaration for tcdefault, and change the *.css mapping to use just default. As someone else pointed out, default is already declared in conf/web.xml to use the proper servlet class, and conf/web.xml is automatically included in for every webapp. Are there any drawbacks to this method? None that I can think of. - Chuck THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers. - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
CSS not being used when a Servlet is involved
Hi, I have the following problem: If I include the Servlet using the jsp:include tag and if the web.xml file is configured correctly, it will invoke the Servlet, but the CSS won't load. If I change the URL pattern, the Servlet won't be invoked (with a Resource unavailable error) but the CSS is rendered. Here's where the files are: $CATALINA_HOME/webapps/ROOT/doc/o23/index.jsp (deze jsp file roept dus de StatistiekServlet aan) $CATALINA_HOME/webapps/ROOT/doc/o23/StatistiekServlet $CATALINA_HOME/webapps/ROOT/WEB-INF/classes/o23/StatistiekServlet $CATALINA_HOME/webapps/ROOT/WEB-INF/classes/StatistiekServlet (Yes, I have three locations for the statistics servlet. I don't know where to place it!) Here's the code for the servlet in web.xml servlet servlet-nameStatistiekServlet/servlet-name servlet-classStatistiekServlet/servlet-class /servlet servlet-mapping servlet-nameStatistiekServlet/servlet-name url-pattern//url-pattern /servlet-mapping I always have this problem with Servlets. Is there any way to use CSS (and similar things...) with Servlets without too much trouble (like, changing some configuration settings)? Thanks in advance! (Yes, I've searched but I couldn't find a helping answer). -- View this message in context: http://www.nabble.com/CSS-not-being-used-when-a-Servlet-is-involved-tf2521410.html#a7032844 Sent from the Tomcat - User mailing list archive at Nabble.com. - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: CSS not being used when a Servlet is involved
Robbert, (Yes, I have three locations for the statistics servlet. I don't know where to place it!) See below. $CATALINA_HOME/webapps/ROOT/doc/o23/index.jsp (deze jsp file roept dus de StatistiekServlet aan) This should be fine. $CATALINA_HOME/webapps/ROOT/doc/o23/StatistiekServlet This will not work: the servlet is not in the classpath (unless you've done something really weird). $CATALINA_HOME/webapps/ROOT/WEB-INF/classes/StatistiekServlet This won't work: servlets basically do not work if they are not in packages. $CATALINA_HOME/webapps/ROOT/WEB-INF/classes/o23/StatistiekServlet This is the only one that will work, and your servlet must have a package o23; declaration at the top. You'll need your web.xml to look like this: servlet servlet-nameStatistiekServlet/servlet-name servlet-classo23.StatistiekServlet/servlet-class /servlet I always have this problem with Servlets. Is there any way to use CSS (and similar things...) with Servlets without too much trouble (like, changing some configuration settings)? Can you give an example of the URL being used when trying to load a CSS file? How about the servlet? You should make the changes noted above and tell us if it helped. Then, we can deal with the CSS issue. -chris signature.asc Description: OpenPGP digital signature
Re: CSS not being used when a Servlet is involved
1. The location of servlet classes is documented in the spec. Place them in either a directory structure that reflects the package structure under WEB-INF/classes or in a jar file whose internal folder structure reflects the package structure. Ex.: Suppose you have the class StatistiekServlet defined to be in package o23 (sound familiar?). That class file would be placed in WEB-INF/classes/o23 2. How are you including the css -- inline or via a link tag? If via a link tag, that is pulled via a separate request to the server. --David Robbert wrote: Hi, I have the following problem: If I include the Servlet using the jsp:include tag and if the web.xml file is configured correctly, it will invoke the Servlet, but the CSS won't load. If I change the URL pattern, the Servlet won't be invoked (with a Resource unavailable error) but the CSS is rendered. Here's where the files are: $CATALINA_HOME/webapps/ROOT/doc/o23/index.jsp (deze jsp file roept dus de StatistiekServlet aan) $CATALINA_HOME/webapps/ROOT/doc/o23/StatistiekServlet $CATALINA_HOME/webapps/ROOT/WEB-INF/classes/o23/StatistiekServlet $CATALINA_HOME/webapps/ROOT/WEB-INF/classes/StatistiekServlet (Yes, I have three locations for the statistics servlet. I don't know where to place it!) Here's the code for the servlet in web.xml servlet servlet-nameStatistiekServlet/servlet-name servlet-classStatistiekServlet/servlet-class /servlet servlet-mapping servlet-nameStatistiekServlet/servlet-name url-pattern//url-pattern /servlet-mapping I always have this problem with Servlets. Is there any way to use CSS (and similar things...) with Servlets without too much trouble (like, changing some configuration settings)? Thanks in advance! (Yes, I've searched but I couldn't find a helping answer). - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: CSS not being used when a Servlet is involved
Christopher Schultz-2 wrote: Robbert, (Yes, I have three locations for the statistics servlet. I don't know where to place it!) See below. $CATALINA_HOME/webapps/ROOT/doc/o23/index.jsp (deze jsp file roept dus de StatistiekServlet aan) This should be fine. Sorry about the Dutch, I forgot to edit that. The part in parenthesis says that it's the JSP that calls the Servlet. The basic idea is this: the JSP calls the Servlet and the Servlet fetches statistics and stores them. Invoking it works fine, even without the package declaration. $CATALINA_HOME/webapps/ROOT/doc/o23/StatistiekServlet This will not work: the servlet is not in the classpath (unless you've done something really weird). Can't say I have, no. $CATALINA_HOME/webapps/ROOT/WEB-INF/classes/StatistiekServlet This won't work: servlets basically do not work if they are not in packages. Gotcha. $CATALINA_HOME/webapps/ROOT/WEB-INF/classes/o23/StatistiekServlet This is the only one that will work, and your servlet must have a package o23; declaration at the top. Makes sense, yes. You'll need your web.xml to look like this: servlet servlet-nameStatistiekServlet/servlet-name servlet-classo23.StatistiekServlet/servlet-class /servlet Done. Thanks for that. I'm not all that used when working with packages. I always have this problem with Servlets. Is there any way to use CSS (and similar things...) with Servlets without too much trouble (like, changing some configuration settings)? Can you give an example of the URL being used when trying to load a CSS file? How about the servlet? You should make the changes noted above and tell us if it helped. Then, we can deal with the CSS issue. -chris The URL used to call the index.jsp page is as follows: http://localhost:8080/doc/o23/index.jsp The CSS is loaded with the following tag: link href=style.css rel=stylesheet type=text/css / The Servlet is now placed in $CATALINA_HOME/webapps/ROOT/WEB-INF/classes/o23/StatistiekServlet, and I'm calling the Servlet with jsp:include page=StatistiekServlet flush=true / I hope that that's enough information and that I didn't mess up on posting. This is my first time posting like this. -- View this message in context: http://www.nabble.com/CSS-not-being-used-when-a-Servlet-is-involved-tf2521410.html#a7035402 Sent from the Tomcat - User mailing list archive at Nabble.com. - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: CSS not being used when a Servlet is involved
David Smith-2 wrote: 1. The location of servlet classes is documented in the spec. Place them in either a directory structure that reflects the package structure under WEB-INF/classes or in a jar file whose internal folder structure reflects the package structure. Ex.: Suppose you have the class StatistiekServlet defined to be in package o23 (sound familiar?). That class file would be placed in WEB-INF/classes/o23 Yes, I did that now. I now have the following package declaration in StatistiekServlet: o23 And the servlet is placed in $CATALINA_HOME/webapps/ROOT/WEB-INF/classes/o23 David Smith-2 wrote: 2. How are you including the css -- inline or via a link tag? If via a link tag, that is pulled via a separate request to the server. --David I'm using a link tag. It works fine if I take out the lines in web.xml that define the Servlet + Servlet Mapping. But if I add them back, it doesn't work anymore. What do you mean exactly that the tag is pulled via a seperate request to the server? -- View this message in context: http://www.nabble.com/CSS-not-being-used-when-a-Servlet-is-involved-tf2521410.html#a7035535 Sent from the Tomcat - User mailing list archive at Nabble.com. - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: CSS not being used when a Servlet is involved
From: Robbert [mailto:[EMAIL PROTECTED] Subject: Re: CSS not being used when a Servlet is involved I'm using a link tag. It works fine if I take out the lines in web.xml that define the Servlet + Servlet Mapping. But if I add them back, it doesn't work anymore. Does your mapping use /? This means the servlet will be invoked for every request to the webapp that isn't handled by some other mapping. Perhaps you need to change it to be more specific. - Chuck THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers. - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: CSS not being used when a Servlet is involved
From: Robbert [mailto:[EMAIL PROTECTED] Subject: Re: CSS not being used when a Servlet is involved I'm calling the Servlet with jsp:include page=StatistiekServlet flush=true / Shouldn't the above be: jsp:include page=/StatistiekServlet flush=true / Isn't the leading slash required to make the reference relative to the context rather than the location of the JSP? - Chuck THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers. - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: CSS not being used when a Servlet is involved
Caldarale, Charles R wrote: From: Robbert [mailto:[EMAIL PROTECTED] Subject: Re: CSS not being used when a Servlet is involved I'm calling the Servlet with jsp:include page=StatistiekServlet flush=true / Shouldn't the above be: jsp:include page=/StatistiekServlet flush=true / Isn't the leading slash required to make the reference relative to the context rather than the location of the JSP? - Chuck Ah, yes. I mistook the / for a \ in my rush.. But it says jsp:include page=/StatistiekServlet flush=true / where I want to include the Servlet. -- View this message in context: http://www.nabble.com/CSS-not-being-used-when-a-Servlet-is-involved-tf2521410.html#a7036862 Sent from the Tomcat - User mailing list archive at Nabble.com. - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: CSS not being used when a Servlet is involved
Caldarale, Charles R wrote: From: Robbert [mailto:[EMAIL PROTECTED] Subject: Re: CSS not being used when a Servlet is involved I'm using a link tag. It works fine if I take out the lines in web.xml that define the Servlet + Servlet Mapping. But if I add them back, it doesn't work anymore. Does your mapping use /? This means the servlet will be invoked for every request to the webapp that isn't handled by some other mapping. Perhaps you need to change it to be more specific. - Chuck My Servlet-mapping (if you mean that) is as follows: servlet-mapping servlet-nameStatistiekServlet/servlet-name url-pattern//url-pattern /servlet-mapping Here's something someone else posted: quote=David Smith-2 2. How are you including the css -- inline or via a link tag? If via a link tag, that is pulled via a separate request to the server. Combining that with what you just said, I assume that you're basically saying that my servlet tries to handle the link ... tag that contains the URL to my CSS, but fails miserably in the process? If so, then how do I change my web.xml file in such a manner that the Servlet leaves the CSS alone? I've tried reading the template web.xml.txt file, but I'm still relatively new to this so I'm not sure just what to do to change it so that it leaves the CSS alone. -- View this message in context: http://www.nabble.com/CSS-not-being-used-when-a-Servlet-is-involved-tf2521410.html#a7037029 Sent from the Tomcat - User mailing list archive at Nabble.com. - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: CSS not being used when a Servlet is involved
I think the essential problem in the css is the client is attempting to guess the location of the css based on a relative URL and the address of the main page. You could try giving it an absolute path: ${pageContext.request.contextPath}/myStyles.css The client will receive an absolute path to the css file on your server. Added benefit is the webapp can be deployed under any number of paths and still provide the correct absolute path to the css. --David Robbert wrote: Caldarale, Charles R wrote: From: Robbert [mailto:[EMAIL PROTECTED] Subject: Re: CSS not being used when a Servlet is involved I'm using a link tag. It works fine if I take out the lines in web.xml that define the Servlet + Servlet Mapping. But if I add them back, it doesn't work anymore. Does your mapping use /? This means the servlet will be invoked for every request to the webapp that isn't handled by some other mapping. Perhaps you need to change it to be more specific. - Chuck My Servlet-mapping (if you mean that) is as follows: servlet-mapping servlet-nameStatistiekServlet/servlet-name url-pattern//url-pattern /servlet-mapping Here's something someone else posted: quote=David Smith-2 2. How are you including the css -- inline or via a link tag? If via a link tag, that is pulled via a separate request to the server. Combining that with what you just said, I assume that you're basically saying that my servlet tries to handle the link ... tag that contains the URL to my CSS, but fails miserably in the process? If so, then how do I change my web.xml file in such a manner that the Servlet leaves the CSS alone? I've tried reading the template web.xml.txt file, but I'm still relatively new to this so I'm not sure just what to do to change it so that it leaves the CSS alone. - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: CSS not being used when a Servlet is involved
From: Robbert [mailto:[EMAIL PROTECTED] Subject: RE: CSS not being used when a Servlet is involved Combining that with what you just said, I assume that you're basically saying that my servlet tries to handle the link tag that contains the URL to my CSS, but fails miserably in the process? Yes, that's what I think is going on. If so, then how do I change my web.xml file in such a manner that the Servlet leaves the CSS alone? I don't know how your app is architected, so I don't know if you want nearly all URI references to go to the StatistiekServlet, or just specific ones. If it's just specific, use those on the url-pattern, rather than just a slash. If StatistiekServlet should process everything but the .css files, try putting this in your web.xml: servlet servlet-nametcdefault/servlet-name servlet-classorg.apache.catalina.servlets.DefaultServlet/servlet-clas s /servlet servlet-mapping servlet-nametcdefault/servlet-name url-pattern*.css/url-pattern /servlet-mapping This would be in addition to what you already have. - Chuck P.S. This thread is converging with another one from today... THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers. - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]