Hi ALL, I am using JSDK2.1, I am trying to compile a small servlet, i get .java file as well .class file but it doesnt create a .html page , do i need to create a html page and the embed the servlet code? Thanks very much
You would need to create an html or jsp file to run the servlet. A servlet is a compiled class module where the source is in the .java file and the compiled class is in the .class file. Let me know if you need additional information.
NO! The servlet does not need an HTML or JSP file. The servlet can simply write HTML. The class file is run by specifying the servlet URL the same way that you run a CGI program. Compiling a servlet does not magically create an HTML file. Running the compiled class file from the browser thorugh the web server sends HTML to the browser. Steps: 1) Create .java 2) Compile .java into .class 3) run the class file from your browser specifying the address of your web server's servlet directory (e.g. http://www.a.com/servlet/MyServlet) [This message has been edited by Tom P (edited May 15, 2000).]
Originally posted by Shiva: Hi ALL, I am using JSDK2.1, I am trying to compile a small servlet, i get .java file as well .class file but it doesnt create a .html page , do i need to create a html page and the embed the servlet code? Thanks very much
You generally create a servlet and then simply compile it. It never generates an HTML file. Withing this servlet you would output the HTML using System.out.println. Of course this meant that the HTML was not particularly easy to maintain so JSPs were created. These look like normal HTML except they has JSP tags inside them. They enable you to maintain the HTML as you would a normal page. At run time when the JSP is requested for the first time, the JSP page is converted into a servlet (which contains the less manageable system.out.println commands) and then this servlet is compiled as per any other servlet. Hope this helps.