You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by gabor <ga...@nekomancer.net> on 2005/05/27 14:16:17 UTC

my build "structure"..opinions wanted

hi,

i'm starting a project using jsp + javaBeans..
i've worked with java a lot, but i have not much experience with web
applications..

for now my idea is that the application will be using javabeans, and jsp
for displaying the data...

i use eclipse for the development, which nicely compiles every source
file automatically when i edit them.

that's why i came up with the following idea:

i'll create a directory in tomcat/webapps (let's call it 'mywebapp').
put my source files into mywebapp/WEB-INF/src, and instruct eclipse to
put the compiled .class files into mywebapp/WEB-INF/classes.

this way, i simply edit the files, press ctrl-s (to save them),
switch to the browser window, and press refresh, and already i get the
new results (because eclipse already compiled the file, and tomcat
detected the change).

i tested this approach, and it works ok.

is this a suitable approach? are there any dangers with this approach?

gabor


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: my build "structure"..opinions wanted

Posted by Anto Paul <an...@gmail.com>.
On 5/27/05, gabor <ga...@nekomancer.net> wrote:

> i'll create a directory in tomcat/webapps (let's call it 'mywebapp').
> put my source files into mywebapp/WEB-INF/src, and instruct eclipse to
> put the compiled .class files into mywebapp/WEB-INF/classes.
> 
> this way, i simply edit the files, press ctrl-s (to save them),
> switch to the browser window, and press refresh, and already i get the
> new results (because eclipse already compiled the file, and tomcat
> detected the change).
> 

How you will deploy the application in test and production
environments. Here I use Eclipse and Ant. I disable the reloadable
feature and uses the manager application to reload the application. If
reloadable is enabled TC will reload the application every time I
compile a Java file.

-- 
rgds
Anto Paul

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


RE: my build "structure"..opinions wanted

Posted by Steve Kirk <to...@web-startup.co.uk>.
Precompiled JSPs do 2 steps - JSP to Java, then Java to pcode, which can
then be run by TC.  The compiled JSPs end up as class files, mine end up in
in the
%catalina_home%\work\[enginename]\[hostname]\[webappname]\org\apache\jsp\WEB
_INF\jsp directory (because the source JSP files are in WEB-INF\jsp).

Without precomp, TC compiles each JSP on the fly, the first time that it is
accessed, which slows down execution.

I've never used Eclipse so was just interested.  NetBeans does not by
default do precomp, or even auto compile of servlets on save, although
because it is based on Ant, most things are possible with a little
scripting.

> -----Original Message-----
> From: gabor [mailto:gabor@nekomancer.net] 
> Sent: Friday 27 May 2005 15:12
> To: Tomcat Users List
> Subject: Re: my build "structure"..opinions wanted
> 
> 
> On Fri, May 27, 2005 at 01:29:50PM +0100, Steve Kirk wrote:
> > 
> > 
> > Your approach that sounds a quite practical solution to me. 
>  Does eclipse
> > precompile JSPs for you too?
> 
> no.. well, i don't know.. where should the compiled jsp files? be 
> (so i can check :)..
> 
> but anyway, as long as tomcat recompiles them on change, it's ok :)
> 
> gabor
> 
>  
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
> 
> 



---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: my build "structure"..opinions wanted

Posted by gabor <ga...@nekomancer.net>.
On Fri, May 27, 2005 at 01:29:50PM +0100, Steve Kirk wrote:
> 
> 
> Your approach that sounds a quite practical solution to me.  Does eclipse
> precompile JSPs for you too?

no.. well, i don't know.. where should the compiled jsp files? be 
(so i can check :)..

but anyway, as long as tomcat recompiles them on change, it's ok :)

gabor

 

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: my build "structure"..opinions wanted

Posted by Tim Diggins <su...@red56.co.uk>.
BTW: (long reply... apologies - much of this reflection on current 
development of most use to myself and my company, but just in case of 
use to someone else, I hit send anyway... )

---------------

I think it's best not to deviate TOO far from the model shown in 
Application Developers Guide in the tomcat docs (really, this is a 
fantastic starting point I think - 
http://jakarta.apache.org/tomcat/tomcat-5.0-doc/appdev/index.html or the 
5.5 version ). I started using the sysdeo tomcat plugin for eclipse, but 
no longer use it as I know exactly where I am with explicit ant tasks.

The build task in the application developers guide build.xml, does build 
to an explicit and separate "build" folder and then compiles & copies 
across stuff from the web and src folders. (Note that it cleverly copies 
across any non-java files from the src folder hierarchy to the 
build/web/WEB-INF/classes hierarchy, meaning that you keep the "source" 
for your classpath located .properties (etc) files in the src directory 
- where it should be)

Practically speaking I actually don't have a separate build directory, 
instead I build to the web/WEB-INF/classes directory but I do copy 
across properties files from the web/WEB-INF/src directory... I deploy 
my "build" directory directly to my localhost tomcat and reload it 
(using the tomcat "reload" ant-task (optional tasks which require 
catalina-ant.jar*) - this does the manager stuff for you.

The advantage of having the non classpath items not being copied is 
particularly valuable when you are trying to tweak velocity templates - 
there's no need to reload the whole webapp simply to correct some typos 
in your velocity scripts) - again I'm not unit testing view outputs, at 
present, so this point of view may change as well

I do use the dist task (building a war file) and deploying a war when 
I'm deploying the webapp to a different (shared) machine (and often I 
have a version/iteration-specific context name (like projectname-vX so 
that I know which (repository version or iteration number) version is 
being shown).

hth

Tim

*Note: It's worth having machine-specifc properties (the localhost 
tomcat manager url, user and password) in a separate 
build.local.properties (NOT in the build.xml file), which is then NOT 
committed to your repository (as it will vary from machine to machine) - 
then ideally your ant tasks will check that these properties are around 
and if not throw up a helpful message.



Kenneth Jensen wrote:
> I have this target in my build-file. This makes Eclipse transfer my
> webapp in a jar file to the Tomcat server, which then automatically
> reloads it.
> 
> <target name="deploy" depends="jar" description="Deploy webapp to server">
>     <copy file="${jarfile}" todir="${webappdir}/WEB-INF/lib" />
>     <exec executable="/usr/bin/scp" >
>        <arg file="${jarfile}"/>
>        <arg value="tomcat.mydomain.dk:${webappdir}/WEB-INF/lib"/>
>     </exec>
> </target>
> 
> ---
> Cheers,
> Kenneth
> 
> 
> 
> On 5/27/05, Steve Kirk <to...@web-startup.co.uk> wrote:
> 
>>Don't leave the source on the production server, but it's fine in
>>development.  Strictly speaking your source files are inaccessible by web
>>clients if they are under WEB-INF, but better safe than sorry.  Why not
>>store the src in another folder altogether - eclipse won't care where it is
>>presumably, and this is slightly better practice.
>>
>>The other approach is to build a jarfile from a build script (e.g. using
>>ant), then copy the jar to the webapps/ directory, TC will auto-deply it.
>>Some would say this is the only way to do it.  However it does slow things
>>down when you are making frequent small changes to code.  For my money, the
>>value of a jar is ease of portability, which is a factor if you are writing
>>for true cross-container support.
>>
>>I built classes direct to classes/ for a long time, then made the effort to
>>switch to jar deployment in development, after being persuaded by people on
>>this list.  I'm glad I've done both, but to be honest I think I do prefer
>>building to classes, as it's quicker and I can't see a disadvantage to it
>>during dev.
>>
>>Your approach that sounds a quite practical solution to me.  Does eclipse
>>precompile JSPs for you too?
>>
>>One other thing to watch is that logging.properties and properties files go
>>in the classes/ folder, so if you use these, be careful that eclipse does
>>not delete them when rebuilding your classes.
>>
>>
>>>-----Original Message-----
>>>From: gabor [mailto:gabor@nekomancer.net]
>>>Sent: Friday 27 May 2005 13:16
>>>To: tomcat-user@jakarta.apache.org
>>>Subject: my build "structure"..opinions wanted
>>>
>>>
>>>
>>>hi,
>>>
>>>i'm starting a project using jsp + javaBeans..
>>>i've worked with java a lot, but i have not much experience with web
>>>applications..
>>>
>>>for now my idea is that the application will be using
>>>javabeans, and jsp
>>>for displaying the data...
>>>
>>>i use eclipse for the development, which nicely compiles every source
>>>file automatically when i edit them.
>>>
>>>that's why i came up with the following idea:
>>>
>>>i'll create a directory in tomcat/webapps (let's call it 'mywebapp').
>>>put my source files into mywebapp/WEB-INF/src, and instruct eclipse to
>>>put the compiled .class files into mywebapp/WEB-INF/classes.
>>>
>>>this way, i simply edit the files, press ctrl-s (to save them),
>>>switch to the browser window, and press refresh, and already i get the
>>>new results (because eclipse already compiled the file, and tomcat
>>>detected the change).
>>>
>>>i tested this approach, and it works ok.
>>>
>>>is this a suitable approach? are there any dangers with this approach?
>>>
>>>gabor
>>>
>>>
>>>---------------------------------------------------------------------
>>>To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
>>>For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>>>
>>>
>>
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>>
>>
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
> 
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: my build "structure"..opinions wanted

Posted by Kenneth Jensen <xm...@gmail.com>.
I have this target in my build-file. This makes Eclipse transfer my
webapp in a jar file to the Tomcat server, which then automatically
reloads it.

<target name="deploy" depends="jar" description="Deploy webapp to server">
    <copy file="${jarfile}" todir="${webappdir}/WEB-INF/lib" />
    <exec executable="/usr/bin/scp" >
       <arg file="${jarfile}"/>
       <arg value="tomcat.mydomain.dk:${webappdir}/WEB-INF/lib"/>
    </exec>
</target>

---
Cheers,
Kenneth



On 5/27/05, Steve Kirk <to...@web-startup.co.uk> wrote:
> 
> Don't leave the source on the production server, but it's fine in
> development.  Strictly speaking your source files are inaccessible by web
> clients if they are under WEB-INF, but better safe than sorry.  Why not
> store the src in another folder altogether - eclipse won't care where it is
> presumably, and this is slightly better practice.
> 
> The other approach is to build a jarfile from a build script (e.g. using
> ant), then copy the jar to the webapps/ directory, TC will auto-deply it.
> Some would say this is the only way to do it.  However it does slow things
> down when you are making frequent small changes to code.  For my money, the
> value of a jar is ease of portability, which is a factor if you are writing
> for true cross-container support.
> 
> I built classes direct to classes/ for a long time, then made the effort to
> switch to jar deployment in development, after being persuaded by people on
> this list.  I'm glad I've done both, but to be honest I think I do prefer
> building to classes, as it's quicker and I can't see a disadvantage to it
> during dev.
> 
> Your approach that sounds a quite practical solution to me.  Does eclipse
> precompile JSPs for you too?
> 
> One other thing to watch is that logging.properties and properties files go
> in the classes/ folder, so if you use these, be careful that eclipse does
> not delete them when rebuilding your classes.
> 
> > -----Original Message-----
> > From: gabor [mailto:gabor@nekomancer.net]
> > Sent: Friday 27 May 2005 13:16
> > To: tomcat-user@jakarta.apache.org
> > Subject: my build "structure"..opinions wanted
> >
> >
> >
> > hi,
> >
> > i'm starting a project using jsp + javaBeans..
> > i've worked with java a lot, but i have not much experience with web
> > applications..
> >
> > for now my idea is that the application will be using
> > javabeans, and jsp
> > for displaying the data...
> >
> > i use eclipse for the development, which nicely compiles every source
> > file automatically when i edit them.
> >
> > that's why i came up with the following idea:
> >
> > i'll create a directory in tomcat/webapps (let's call it 'mywebapp').
> > put my source files into mywebapp/WEB-INF/src, and instruct eclipse to
> > put the compiled .class files into mywebapp/WEB-INF/classes.
> >
> > this way, i simply edit the files, press ctrl-s (to save them),
> > switch to the browser window, and press refresh, and already i get the
> > new results (because eclipse already compiled the file, and tomcat
> > detected the change).
> >
> > i tested this approach, and it works ok.
> >
> > is this a suitable approach? are there any dangers with this approach?
> >
> > gabor
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
> >
> >
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
> 
>

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


RE: my build "structure"..opinions wanted

Posted by Steve Kirk <to...@web-startup.co.uk>.
Don't leave the source on the production server, but it's fine in
development.  Strictly speaking your source files are inaccessible by web
clients if they are under WEB-INF, but better safe than sorry.  Why not
store the src in another folder altogether - eclipse won't care where it is
presumably, and this is slightly better practice.

The other approach is to build a jarfile from a build script (e.g. using
ant), then copy the jar to the webapps/ directory, TC will auto-deply it.
Some would say this is the only way to do it.  However it does slow things
down when you are making frequent small changes to code.  For my money, the
value of a jar is ease of portability, which is a factor if you are writing
for true cross-container support.

I built classes direct to classes/ for a long time, then made the effort to
switch to jar deployment in development, after being persuaded by people on
this list.  I'm glad I've done both, but to be honest I think I do prefer
building to classes, as it's quicker and I can't see a disadvantage to it
during dev.

Your approach that sounds a quite practical solution to me.  Does eclipse
precompile JSPs for you too?

One other thing to watch is that logging.properties and properties files go
in the classes/ folder, so if you use these, be careful that eclipse does
not delete them when rebuilding your classes.

> -----Original Message-----
> From: gabor [mailto:gabor@nekomancer.net] 
> Sent: Friday 27 May 2005 13:16
> To: tomcat-user@jakarta.apache.org
> Subject: my build "structure"..opinions wanted
> 
> 
> 
> hi,
> 
> i'm starting a project using jsp + javaBeans..
> i've worked with java a lot, but i have not much experience with web
> applications..
> 
> for now my idea is that the application will be using 
> javabeans, and jsp
> for displaying the data...
> 
> i use eclipse for the development, which nicely compiles every source
> file automatically when i edit them.
> 
> that's why i came up with the following idea:
> 
> i'll create a directory in tomcat/webapps (let's call it 'mywebapp').
> put my source files into mywebapp/WEB-INF/src, and instruct eclipse to
> put the compiled .class files into mywebapp/WEB-INF/classes.
> 
> this way, i simply edit the files, press ctrl-s (to save them),
> switch to the browser window, and press refresh, and already i get the
> new results (because eclipse already compiled the file, and tomcat
> detected the change).
> 
> i tested this approach, and it works ok.
> 
> is this a suitable approach? are there any dangers with this approach?
> 
> gabor
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
> 
> 



---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org