Location: http://www.jguru.com/faq/Servlets
Ownership: http://www.jguru.com/misc/user-agree.jsp#ownership.
How do I set my CLASSPATH for servlets? Ownership: http://www.jguru.com/misc/user-agree.jsp#ownership.
Location: http://www.jguru.com/faq/view.jsp?EID=141
Created: Sep 3, 1999 Modified: 2001-05-05 14:19:15.228
Author: Alex Chaffee (http://www.jguru.com/guru/viewbio.jsp?EID=3)
That depends.
For developing servlets, just make sure that the JAR file containing javax.servlet.* is in your CLASSPATH, and use your normal development tools (javac and so forth).
- For JSDK: JSDK_HOME/lib/jsdk.jar
- For Tomcat: TOMCAT_HOME/lib/servlet.jar
The Servlets 2.2 spec says that the following should automatically be included by the container, so you shouldn't have to add them to your CLASSPATH manually. (Classloader implementations are notoriously buggy, though, so YMMV.)
- classes in the webapp/WEB-INF/classes directory
- JAR files in the webapp/WEB-INF/lib directory
This applies to webapps that are present on the filesystem, and to webapps that have been packaged into a WAR file and placed in the container's "webapps" directory. (e.g. TOMCAT_HOME/webapps/myapp.war)
The Complete CLASSPATH Guide for Servlets (http://www.meangene.com/java/classpath.html) by Gene McKenna (mckenna@meangene.com) has detailed instructions on how to set your CLASSPATH for JavaWebServer and JRun. Comments and alternative answers
![]() | Important precision : Under Apache (at least with... Author: Denis BUCHER (http://www.jguru.com/guru/viewbio.jsp?EID=7742), Jan 22, 2000 Important precision : Under Apache (at least with jserv under Linux) you SHOULD NOT put this in any system path, as it won't work. You must put the new path into jserv.properties file, that you located maybe into your apache config dir !!! |
![]() | I've found it simpler to just copy the JAR file to... jre/lib/ext Author: John Zukowski (http://www.jguru.com/guru/viewbio.jsp?EID=7), Jun 15, 2000 I've found it simpler to just copy the JAR file to the extensions directory of your runtime: under your JDK directory, as in: c:\jdk1.3\jre\lib\ext |
![]() | If you are using JRun (atleast with v2.3.3), adding... Author: sharad gupta (http://www.jguru.com/guru/viewbio.jsp?EID=100198), Jul 21, 2000 If you are using JRun (atleast with v2.3.3), adding servlet classes in system path won't work. Instead add the path in jsm.properties file. |
![]() | Unfortunately, Jaz' extension solution doesn't work... Author: Alex Chaffee (http://www.jguru.com/guru/viewbio.jsp?EID=3), Sep 17, 2000 Unfortunately, Jaz' extension solution doesn't work for some JARs, notably XML parsers. I'm not exactly sure why; perhaps it's package name collision. The webapp solution (WEB-INF/lib) is preferred. |
![]() | I would not hesitate to have a static block in one... Author: Aprameya Paduthonse (http://www.jguru.com/guru/viewbio.jsp?EID=4707), Feb 1, 2001 I would not hesitate to have a static block in one of my early loaded servlets to list the environment parameters static { Properties envProps = System.getProperties(); System.out.println("__________________________ BEGIN JAVA SETTINGS _______________________________"); for (Enumeration e = envProps.propertyNames() ; e.hasMoreElements() ;) { String prop = (String)e.nextElement(); System.out.println(prop + " : " + envProps.getProperty(prop)); } System.out.println("_____________________________END JAVA SETTINGS _______________________________"); }
Location: http://www.jguru.com/faq/view.jsp?EID=142 Created: Sep 3, 1999 Modified: 1999-12-22 11:09:48.603 Author: Alex Chaffee (http://www.jguru.com/guru/viewbio.jsp?EID=3) For Java Web Server:
Comments and alternative answers
Location: http://www.jguru.com/faq/view.jsp?EID=143 Created: Sep 3, 1999 Modified: 2000-05-21 14:36:17.445 Author: Alex Chaffee (http://www.jguru.com/guru/viewbio.jsp?EID=3) If you use your servlet inside an SSI, you must use res.getOutputStream() and not res.getWriter(). Check the server error logs for more details. Comments and alternative answers
Location: http://www.jguru.com/faq/view.jsp?EID=144 Created: Sep 3, 1999 Modified: 2000-08-10 10:04:27.869 Author: Alex Chaffee (http://www.jguru.com/guru/viewbio.jsp?EID=3) The easy way is, just support POST, then have your doGet method call your doPost method:
public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { doPost(req, res); }Note that implementing the <mono>service()</mono> method is usually not what you want to do, since HttpServlet provides its own implementation of <mono>service()</mono> that turns around and calls <mono>doGet(), doPost(),</mono> etc. Lee Crocker (LCrocker@INFORMANT.COM): "It's probably cleaner not to override <mono>service()</mono> when extending HttpServlet. The existing service method just calls <mono>doGet()</mono>, <mono>doPost()</mono>, etc. as appropriate, so you can certainly override it if you feel like it, but then you wind up not only treating GET and POST identically, but also all other HTTP commands, like HEAD, TRACE, and OPTIONS. If you want GET and POST to do the same thing, just have <mono>doGet()</mono> and <mono>doPost()</mono> call the same private method that does all the work." See also:
|
No comments:
Post a Comment