Hi! After much experimentation, I have been able to make a lot of progress (see my previous post attached below). I am posting this in hopes of helping some other soul who might be stuck in the future (the biggest lessons are in c. and e. below). Primarily my interest was in starting up the servlet server from within an IDE so I could debug. Here are my experiences using Win-98 and JSWDK-1.0.1. It should be similar for UNIX, I'll try later under my Redhat-6.1 installation (which is what I prefer, but at this point I had to try under Win-98 for various reasons). a) Use JSWDK-1.0.1 over the JSDK-2.1, both from Sun. Both are Sun Servlet API 2.1 compliant but JSDK-1.0.1 has more bug-fixes over JSDK-2.1. For one, the "HTTP POST/Connection reset by peer" problem with JSDK-2.1 and Win-95/Win-98 seems to have been fixed with JSWDK-1.0.1. Moreover, JSWDK includes the JSP reference implementation. b) Unzip JSWDK into a local directory, and experiment with running the examples first. To do that, in a MS-DOS window cd to the install directory, C:\jswdk-1.0.1 for example, and run "startserver". The JSWDK version of startserver starts the main() method of com.sun.http.shell.Startup and that uses the file ./webserver.xml to configure com.sun.http.server.HttpServer. If everything is succesful, you should be able to use a browser to connect to http://localhost:8080/ and see the example page and navigate to the JSP and Servlet examples from there. c) Next step will be to see if you can create a "WebApplication" stored away from the JSWDK installation/examples and see if you can access the pages/servlets there using startserver to start the server. The webserver.xml config file has a line: <WebApplication id="examples" mapping="/examples" docBase="examples" /> Add another line below it: <WebApplication id="test" mapping="/test" docBase="..\myServlets\examples" /> Here's what I found: the WebApplication docBase has to be RELATIVE to the PARENT DIRECTORY of the WEBSERVER docBase. Let's say that JSWDK is installed in C:\jswdk-1.0.1. By default, the WebServer docBase then is C:\jswdk-1.0.1\webpages. If you want to install your own servlets in C:\myServlets, then the WebApplication docBase should be C:\jswdk-1.0.1\webpages\..\..\myServlets\examples. When you specify the WebApplication docBase, omit the WebServer docBase (i.e. C:\jswdk-1.0.1\webpages\) and the first "..\". d) Copy the JSWDK examples directory to C:\myServlets\examples (or wherever you specified in c. above). Stop (stopserver) and restart (startserver) the web server. You should now be able to browse to http://localhost:8080/test/jsp and http://localhost:8080/test/servlets e) In theory you should be able to change the WebServer docBase (i.e. the root directory for html pages) by specifying the proper "docBase" attribute to the "Service" element in webserver.xml. By default the Service element is defined as <Service id=service0>, and you should be able to change it to <Service id=service0 docBase=\myServlets\webpages">. In practice, I found that this works HALF way. It does change where your WebApplication relative paths should be calculated from. But it still expects your WebServer docBase to be "/webpages" concatenated to the value of the system property "user.dir", which is where you start "startserver" from! So, with our example, the WebServer docBase is always C:\jwsdk-1.0.1\webpages. f) The startserver script takes an argument "-config filename/URL" with which you can specify a different XML file for the server configuration. This does work as expected. In theory, just like the XML file, you should be able to specify "-docbase path-to-webserver-docbase" but that did not work for me either. g) Once you are satisfied with your custom path setups using "startserver" you should be ready to try with an IDE. Of course, what is needed is a replacement for startserver. Here's the class I used (NOTE: docbase was useless :-( ): public class ServletDebug { public static void main(java.lang.String[] args) { String configFile = "\\myServlets\\webserver.xml"; String docBase = "\\myServlets\\webpages"; String[] serverArgs = new String[4]; serverArgs[0] = "-config"; serverArgs[1] = configFile; serverArgs[2] = "-docbase"; serverArgs[3] = docBase; com.sun.web.shell.Startup.main(serverArgs); } } Your servlets go in either webserver-docbase\Web-inf\servlets or in webapplication-docbase\Web-inf\servlets. Also, look at the various "*.properties" files in the WebServer/WebApplication docBases to see what you can do. Note that you should do the following in the ServeltDebug.Main() above to see where the webserver "webpages" directory should be: String sep = System.getProperty("file.separator"); System.out.println(System.getProperty("user.dir") + sep + "webpages"); You should also setup your classpath for your project under your IDE to load all the appropriate Servlet, Server, JSP, etc classes (JAR files) as well as all the beans you use in your servlet/JSP....that is too user/installation-specific for me to go into here. Good luck! This is all I know at this point ;-). Shash PS: One other thing that is still confusing. I have seen many references to JSDK-2.1 with a lib/jsdk.jar file and the sun.servlet.http.HttpServer class. The JSDK-2.1/JSWDK-2.1 do not have this...they have a webserver.jar, servlet.jar files and the com.sun.http.server.HttpServer class. Maybe there was an interim JSDK-2.1...but then it should have been a different version! "Sasvata (Shash) Chatterjee" wrote: > > Hi, > > I need to debug servlets with an IDE. I looked at various resources and books and >was going to use the HttpServer class to start my developmental servlet. However, >there is > a sun.servlet.http.HttpServer (the one most mentioned in books/FAQs/archives) and >the com.sun.web.server.HttpServer that comes with JSDK-2.1 and yet another that comes >with the JSWDK-1.0.1. I think the latter two are the same except the >com.sun.web.shell.Startup for JSDK-2.1 somehow uses "default.cfg" while the >JSWDK-1.0.1 uses "webserver.xml" to configure the server. Very confusing..... > > The question is where are the docs for the com.sun.web.* classes? If not >accessible, what parameters can I pass to com.sun.web.shell.Startup, particularly to >set my docbase and the various webapps/contexts? Or, how can I configure >com.sun.web.server.HttpServer? > > I have tried the following (based on SimpleServer.java in jsdk-2.1/etc): > > HttpServer server = new HttpServer(port, inet, hostname); > try { > URL url = resolveURL(servletsDir); > server.setDocumentBase(url); > server.setTempDir(new File(tempDir)); // Had to add this to prevent >exception > System.out.println("Starting with docbase of: " + url); > server.start(); > } catch (MalformedURLException mue) { > System.out.println("Malformed URL Exception for doc root"); > System.out.println(mue.getMessage()); > } catch (HttpServerException hse) { > System.out.println("Server threw an exception while running"); > System.out.println(hse.getMessage()); > } > > But this way the server will serve-up http://localhost:8080/snoop but not >http://localhost:8080/servlets/snoop or http://localhost:8080/index.html. > > Thanks, > Shash
begin:vcard n:Chatterjee;Sasvata tel;fax:(972) 996-7119 tel;work:(972) 996-6466 x-mozilla-html:TRUE url:http://www.ans.alcatel.com org:Alcatel USA;Optical Networks R&D version:2.1 email;internet:[EMAIL PROTECTED] title:Optical Transport Platforms adr;quoted-printable:;;1225 N. Alma Rd.=0D=0AMS 406-170;Richardson;Texas;75081-2206;USA x-mozilla-cpt:;18240 fn:Sasvata (Shash) Chatterjee end:vcard
