Hi, Just found this forum while searching for a solution to my problem. Please bear with the newbie question. I've just started to learn servlets and have been trying to run my first using J2EE server. I have installed on my Win 98 platform: Sun's JDK1.3 and J2SDKEE1.3. The server runs without any apparant errors. I am learning the basics of this technology by trying to create an HTML page that should communicate, via the HTTP POST method, with a servlet. The HTML page and the (http) servlet are the only components to be developed. There is no EJB component. I wrote the servlet code and also the HTML page and was able to use deploytool to package the required war file and the web.xml file. I can access the web page through the server but when I submit the POST request to the servlet I get a blank page instead of the test message text that the servlet should return. As happened with the poster of this message, no errors/"something wrong" messages are being logged. When viewed, the source of the blank page has a generic code with nothing between the <BODY></BODY> tags. When I change the POST request to a GET request, recompile and redeploy, I get the HTTP 404 file not found error page. Have searched fairly exhausitvely for leads on this but even the documentation seems to be silent on this one (though I'm sure the solution must be quite basic!) Would greatly appreciate any input from you. I can post code snippets if that would be useful, although the servlet is pretty basic receiving a parameter name-value combination and returning a message text through the PrintWriter response. Thanks, B Sahai
Hi, Tell we get the final solution to what has to be done try this. specify your 1. application web Context in the Web Context tab as rahul (Context Root). 2. Click and open the War tree to see your servlet with a globe icon. click on the aliases tab and click the add button. enter /abc/* in the Aliases. Deploy the application Enter http://localhost:8000/rahul/abc/HelloWorldServlet in your browser. It works!!. I have to checkout other options. But guess we have this for now. Answers that i need are 1) Does every Application (War file) i deploy need a Web Context entered in the ContextRoot 2) I have deployed by HelloWorldServlet by entering Aliases as /abc/*. What are the other permutations and combinations for this.
I think the servlet specification will have answers to my questions. ------------------ Mahindrakar IBM Application Server Forum Moderator SCJP2
[This message has been edited by Rahul Mahindrakar (edited May 06, 2001).]
When debugging servlets, you have to proceed step by step. 1. Is the servlet object even being created? - test by putting System.out.println message in the init method. If it is not even being created, you may have a naming or addressing problem. 2. Is the doGet or doPost being called? - Again, use System.out.println to see. 3. Is there an unhandled exception? - Enclose all code in your doGet or doPost in a try-catch block and use System.out.println to dump the exception. 4. If your method for activating the servlet involves complex forms, you may want to a stream capturing utility to see exactly what your browser is sending. You can download the entire debugging chapter from my servlets and JSP book from: http://www.lanw.com/books/servletjsp/default.htm Bill
Joined: May 05, 2001
Rahul, Bill: Thanks for the pointers. Turns out that I had changed the name of the web context of the deployed web component mid-development, but completely missed updating this in the HTML file calling the servlet! (i.e., in the <FORM ACTION="http : //localhost:8000/mdRoot/GetCalcs" METHOD="post"> tag, I didn't update "mdRoot" to reflect the changed context. It works now. Bill: Thanks also for the debugging chapter. I've downloaded it and will prob'ly get around to using the UtilSnoop soon enough. B Sahai