> Writing functions in a JSP page (wrapped in <%! ... %> delimiters) is evil > ... don't even bother learning how to do it.
Well not true Craig! If something is used more than ONCE one should use a method even inside a JSP. One could use custom tags but I believe one should bother to learn <%! ... %>. I recommend it :) > > Craig, > > > > Your response confirms what I thought. My questions was purely educational > > and not that I am having such cases in my code. Thanks for your response. > > Surely no one should put logic in the PL (jsp). But someone could define and > > use a utility method (eg putting a HTML table showing some data eg date etc) > > in jsp. I positive that this is something that could be done if not in > > current JSP version but in future versions. There could be a directive eg > > THIS.doit() that gets translated by the JSP engine into something like > > colrs$jsp.doit() (colrs.jsp is the jsp file). Though it is certainly not > > that important as required but could be done. Perhaps also at instance > > level! > > > > In general, that is what JSP custom tags are for. Among other things, > they let you create arbitrary dynamic output, based on the parameters you > specify for that tag. Good examples to look at include: > > * The JSP standard tag library (available via Apache as the 'standard" > tag library at <http://jakarta.apache.org/taglibs>. > > * Tags that generate arbitrarily complex HTML output, such as the tags > provided by the Struts framework <http://jakarta.apache.org.struts/>. > > However, in none of these cases do you see any processing functions being > stored in a JSP page and called from another - that would not conform to > good object oriented design principles. Instead, you see the common > paradigm of using request attributes to share information within the time > frame of a given request, or session attributes to share information > across multiple requests for a given user. > > Writing functions in a JSP page (wrapped in <%! ... %> delimiters) is evil > ... don't even bother learning how to do it. > > > Thanks > > > > Craig > > > > > > ----- Original Message ----- > > From: "Craig R. McClanahan" <[EMAIL PROTECTED]> > > To: "Tomcat Users List" <[EMAIL PROTECTED]> > > Sent: Tuesday, August 13, 2002 9:18 PM > > Subject: Re: jsp in packages > > > > > > > > > > > > > On Tue, 13 Aug 2002, D Bamud wrote: > > > > > > > Date: Tue, 13 Aug 2002 12:27:53 +0530 > > > > From: D Bamud <[EMAIL PROTECTED]> > > > > Reply-To: Tomcat Users List <[EMAIL PROTECTED]> > > > > To: Tomcat Users List <[EMAIL PROTECTED]> > > > > Subject: jsp in packages > > > > > > > > Q1. Can I declare my jsp files in packages? How? > > > > > > > > > > No. You have zero control over what package the JSP compiler puts your > > > page in, or even what the class name of the generated servlet is. > > > > > > > Q2. I have written a static method in one jsp page. I want to call this > > > > method in another jsp page. How to do it? I do not want to take this > > method > > > > out from the jsp and put into a class (.java) and use it in both the jsp > > > > files. > > > > > > > > > > You need to rethink your "do not want to take this method out" > > > statement. JSP pages and servlets are designed to be totally independent > > > components, and you can't get a reference to an instance of one page or > > > servlet from another. Shared logic and shared data *must* be stored in > > > separate classes. > > > > > > And, you're going to need to understand how to organize your code properly > > > to work on larger scale projects anyway, so now is a good time to start. > > > Hint -- putting logic in your JSP pages is not a good design practice. > > > > > > Craig > > > > > > > > > -- > > > To unsubscribe, e-mail: > > <mailto:[EMAIL PROTECTED]> > > > For additional commands, e-mail: > > <mailto:[EMAIL PROTECTED]> > > > > > > > > > -- > > To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> > > For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> > > > > > > > -- > To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> > For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> > -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
