This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
I'm just looking for some general rules here. Is there a standard place to put JSP scriptlets in the page? For example do people generally put these at the top of the page and then the put the HTML below? Since the JSP is pre preprocessed I figure it doesn't really matter where you put the scriptlets, but I would like to follow the standard procedure, right? Any other tips on the subject appreciated! Thanks! Drew
I personally think that it's best to put the jsp code at the top and the HTML below. Reason is: if you start outputing HTML and then try to do a jsp:forward after that, you will get an error saying sth. like 'You are trying to clear a buffer that's already been cleared'. I am fairly new to jsp and I had this problem for weeks until a kind friend of mine told me to re-structure my code by doing all my java code at the top and then the html part at the bottom. I have been happy since . Also, you should follow the Java Coding Conventions when writing any Java code, including scriplets. It makes your code easier to read by somebody else. The conventions are somewhere on the Sun Website. [This message has been edited by ernest fakudze (edited October 05, 2001).]
In a time of drastic change it is the learners who inherit the future. The learned usually find themselves equipped to live in a world that no longer exists.<br />Eric Hoffer
Of course, if you use a Model-II architecture which puts all of the logic that could POSSIBLY do a forward() (or throw an exception, or any of the other things that make coding JSP's difficult) into a Servlet that you call first, which then populates the session and/or request with JavaBeans that the JSP will display using <jsp:useBean> tags, then everything becomes MUCH simpler. You can refer to my book for examples of doing Model-II (MVC) coding, or I would also refer you to the Struts framework (http://jakarta.apache.org/struts) which enforces Model-II and also automates a lot of the grunt work of coding servlets. Kyle Brown ------------------ Kyle Brown, Author of Enterprise Java (tm) Programming with IBM Websphere See my homepage at http://members.aol.com/kgb1001001 for other WebSphere information.