This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Tomcat and the fly likes to change file (java/jsp) in my project and it don't have the need to restart tomcat Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "to change file (java/jsp) in my project and it don Watch "to change file (java/jsp) in my project and it don New topic
Author

to change file (java/jsp) in my project and it don't have the need to restart tomcat

Dora Di Donato
Ranch Hand

Joined: Nov 27, 2009
Posts: 58
Hy guys,

when I change file in my webproject i have to always testart tomcat. It is possible see the file changed without restart tomcat?
How it is possible?
I read some tutorial and suggest someone to put reloable == true. But I don't understand.
I have tomcat integrate with eclipse.

thank you

dora di donato
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60755
    
  65

A JSP can be changed without worrying about restarting anything.

For a servlet or other Java class, the web app, but not Tomcat, needs to be restarted. Using Tomcat's Manager app makes this rather easy.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
Advanced debuggers let you alter classes at runtime, as does software like JRebel.
Dora Di Donato
Ranch Hand

Joined: Nov 27, 2009
Posts: 58
Hy Tim,
thanks very much.
I will install Tomcat Manager but I try to change the jsp but I don't see the changement after I refresh the jsp.Why?

You consider that i have ant in the project, it can help me?


tahnks

dora di donato
Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
Ant has nothing to do with this. See the answer in http://stackoverflow.com/questions/2004676/why-my-jsp-changes-are-not-reflected-without-restarting-tomcat

You don't need the Tomcat manager to reload JSPs, you need it to reload the entire web app (for when you want to reload Java classes).
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60755
    
  65

Dora Di Donato wrote:but I try to change the jsp but I don't see the changement after I refresh the jsp.Why?

JSPs should be automatically re-translated. Are you perhaps having caching issues?
Dora Di Donato
Ranch Hand

Joined: Nov 27, 2009
Posts: 58
Hi,
ok thanks I understand i put in the my contex.xml the parameter reloadable= true but it don't function.
Ok for the ant I need tomcat manager to be quick in my develop!!


thanks

Dora Di Donato
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15951
    
  19

Changes don't get picked up immediately. Tomcat scans the app for changes every few seconds. Try waiting a little while.


Customer surveys are for companies who didn't pay proper attention to begin with.
Soeren Liebich
Greenhorn

Joined: Apr 21, 2012
Posts: 6
I am also searching for a solution to change, add or remove java or jsf files without restarting the application.
The solution explained here, doesn't work.

I'm using tomcat 7 and having an application in webapps folder.
When I call e.g. "localhost/app/index.xhtml" I see the page as I expected. When I change something in this or another file, waiting some time and reloading this page, nothing changed.
Looking in "work/Catalina/localhost/app" I see no files, which I could delete to retranslate existing source files.

Where does Tomcat 7 store the files or what do I have to do to make changes while running?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60755
    
  65

XHTML files are served as is, so you won't find any compiled sources. Also, it's jut highly likely that your browser is caching the page. Clear the browser cache and you will see the updates.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15951
    
  19

Technically, this should have been a new thread. The original conversation ended a month ago, and we're shifting the subject a bit here. Whatever. Just a reminder that we don't charge people extra for starting their own threads!

"xhtml" is a little vague, unfortunately. In the literal meaning, it would be an HTML file that follows the XML (xhtml) schema. However, such files commonly have the extension of ".htm" or ".html". In fact, I spent some time going in circles the other day because I'd forgotten that when attempting to assemble an eBook file. And HTML files, regardless of which schema/DTD you code them under are served up verbatim to the client by Tomcat.

".xhtml" as a filename extension, however, is the conventional extension for JSF Facelets View Definition Language (VDL) files. In this case, the VDL source is compiled as part of the process of creating the JSF component tree. But the component tree is continually being updated, so chances that changes to those files won't get picked up rapidly are very low. And, in point of fact, I routinely tweak xhtml on the fly as part of the ongoing war between me and CSS to get JSF pages to lay out properly. Since I have Tomcat aimed at my project's target directory, all it takes is a "mvn -o war:exploded" to do so. Followed by "F5" (refresh) to update the browser display.

On the other hand, Tomcat will experience varying behavior for java code and JSPs because the file isn't merely being copied, it's being loaded (as a class) into the JVM. By default, Tomcat will scan the WAR every second or 2 and pick up the class changes at that time, although static initializations done when the class initially loaded may not get repeated. However, if someone has been playing with Tomcat settings, the interval may be different.

It does bear repeating that if you use the common practice of creating a WAR file and copying it to TOMCAT_HOME/webapps, Tomcat will "explode" that WAR into a corresponding directory by default and use the exploded directory as a codebase. If you update the WAR file and copy it again, the exploded copy of the WAR will, however, not be updated. The WAR is only exploded once.

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: to change file (java/jsp) in my project and it don't have the need to restart tomcat
 
Similar Threads
Using Struts with Sun One Studio
Difference between JSP and Servlets
Loading .properties file.
eclipse tomcat context reloading on each jsp save :(
mdotting vs Tomcat part 2