This week's book giveaway is in the OCMJEA forum. We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line! See this thread for details.
Cameron, It depends on what action you want the JSP to perform. Normally, you still need the usual <HTML><BODY></BODY></HTML> tags if you want to present information to the user in a browser but, theoretically, a JSP could perform an 'invisible' task. The JSP compiler translates your JSP into a servlet which, at runtime, outputs all the plain HTML in your JSP as-is and executes the java code in the <% %> tags. What arrives at the browser should be valid and plain HTML (or something the browser can recognise e.g. XML, plain text )
Originally posted by Cameron Park: Hi, I am a bit confused. Does JSP have to be in HTML format?
No. A JSP can be in any format, although in practice you are restricted to text-based formats. Don't forget to set a proper response MIME type for what you're generating. Obviously, whatever format you generate has to be something the client expects (a browser would typically expect plain text or HTML, a WAP phone expects WML, an XSL engine would expect a specific XML vocabulary). But that is really outside the scope of the JSP proper. The JSP engine doesn't care what format you generate. - Peter