Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / First Aid / November 2005

Tip: Looking for answers? Try searching our database.

Tomcat 5.5.12: Output unchanged when servlet changes

Thread view: 
pit.grinja@gmx.de - 27 Nov 2005 13:53 GMT
Hello,
I have recently started to teach myself web programming. ON my system
(Win2K, Java SDK 1.4.2_08) I have installed the lates version of Tomcat
(5.512) and the compatibilty package. I have placed a file
"tableTest.jsp" in a "tabletest" subdirectory of my webapps folder with
the following content:
//tableTest.jsp
<jsp:useBean id="testtable" class="testBeans.MyTestTable">
    <jsp:setProperty name="testtable" property="rowNumber" value="120"/>
    <jsp:setProperty name="testtable" property="colNumber" value="4"/>
</jsp:useBean>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head>
<title>Table Test</title>
</head>
<body>
    <jsp:getProperty name="testtable" property="tableString"/>
</body>
</html>
In "WEB-INF/classes" I have a file "MyTestTable.java" with the
following content:
//MyTableTest.java
package testBeans;
public class MyTestTable
{
   private int rowNumber = 1;
   private int colNumber = 1;
   private String tableString;
   public String getTableString()
   {
       StringBuffer table = new StringBuffer();
       table.append("<table>");
       for (int r=0;r<rowNumber;r++){
           table.append("<tr>");
           for (int c=0;c<colNumber;c++){
               table.append("<td>Cell value");
               table.append(r+1);
               table.append("-");
               table.append(c+1);
               table.append("</td>");
           }
           table.append("</tr>");
       }
       table.append("</table>");
       return table.toString();
   }
   public void setColNumber(int colNumber)
   {
       this.colNumber = colNumber;
   }
   public void setRowNumber(int rowNumber)
   {
       this.rowNumber = rowNumber;
   }
}
When I request "tabletest/tableTest.jsp" I see the expected table. When
I edit the jsp to get a different row number, I see the changes afte
reloading. When I edit the "MyTestTable.java", recompile it, delete the
servlet and the sourcecode from the
"work/Catalina/localhost/tabletest/org/apache/jsp", clear the browser
cache (I use Firefox 1.5beta)  directory and then realod the page,
nothing changes. I can see from the timestamps that both the
MyTestTable.class and the servlet class have been freshly generated,
but I have to shutdown and restart Tomcat before I see the changes. How
is that possible? Is there an internal Tomcat "class caching"
mechanism?
The web.xml file in the WEB-INF folder is empty (i. e. the "web-app"
tag is empty).
Any pointers are appreciated.
Thanks in advance, Piet
VisionSet - 27 Nov 2005 14:22 GMT
> Is there an internal Tomcat "class caching"
> mechanism?

Yes essentially 'The Program' is Tomcat, your webapp is basically a plugin.
You can set Tomcat to reload contexts automatically at a performance hit -
useful for testing.
Basically it scans directories looking for timestamps.

One of the xml files has an 'auto reload contexts' property or something
like that.

--
Mike W
pit.grinja@gmx.de - 27 Nov 2005 17:47 GMT
VisionSet schrieb:
> > Is there an internal Tomcat "class caching"
> > mechanism?
[quoted text clipped - 5 lines]
> One of the xml files has an 'auto reload contexts' property or something
> like that.
Thanks for the quick response.  I checked for the text "reload" in all
xml files in my tomcat directory tree, and didn´t find much useful
hits.  I then started playing around with the web.xml file, and it
turned out that simply changing it (insert a space, then delete it)
would make tomcat to reload servlet. Seems hackish, though. Maybe
things will become clearer over time.
BW, Piet
VisionSet - 27 Nov 2005 18:30 GMT
Thanks for the quick response.  I checked for the text "reload" in all
xml files in my tomcat directory tree, and didn´t find much useful
hits.  I then started playing around with the web.xml file, and it
turned out that simply changing it (insert a space, then delete it)
would make tomcat to reload servlet. Seems hackish, though. Maybe
things will become clearer over time.

Okay I've had a look,
the attribute is in the xml file for the context that represents your web
app.
I've just delved back into servlet stuff myself and this has changed in the
latest tomcat.

Your context name is typically the root name of the url, so the last element
in: localhost/myWebapp

so look for xml called myWebapp.xml under tomcat\conf\Catalina\localhost.
The xml tag is liek this:
- <Context docBase="c:/xxx/webapps" debug="0" privileged="false"
reloadable="true" crossContext="false">

make sure reloadable is 'true'

--
Mike W


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.