tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Craig R. McClanahan" <craig...@apache.org>
Subject Re: jsp in packages
Date Tue, 13 Aug 2002 15:48:51 GMT


On Tue, 13 Aug 2002, D Bamud wrote:

> Date: Tue, 13 Aug 2002 12:27:53 +0530
> From: D Bamud <nougain@cad.delhi.nic.in>
> Reply-To: Tomcat Users List <tomcat-user@jakarta.apache.org>
> To: Tomcat Users List <tomcat-user@jakarta.apache.org>
> 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:tomcat-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:tomcat-user-help@jakarta.apache.org>


Mime
View raw message