Re: Tomcat Settings and Performance

2003-11-16 Thread Tom Parker
On Sat, 2003-11-15 at 05:30, Christopher Schultz wrote:
> Steve,
> 
> > Maybe this is common knowledge, but you know never to do this right?
> > 
> > String x = "a" + "b";
> > 
> > You have to do something like this:
> > 
> > StringBuffer b = new StringBuffer();
> > b.append("a");
> > b.append("b");
> > 
> > Using StringBuffer vastly improves performance.
> 
> Ugh! This is like saying "never use goto". In this example, you are 
> completely wrong:

True, but there is one situation where the advice rings very true.

If you have to build a large string such as a report from some input
like a database result set, then using the + operator in a loop is
asking for poor performance. I recently found such code and replaced it
with a StringBuffer allocated before the loop and turned into a string
after the loop. This appears to have saved the creation of a
stringbuffer and a string for each iteration, as the performance was
radically improved.

In general, I use stringbuffers when my string concatination can't be
done on one line. If it can be done on one line you gain nothing from
explicitly using stringbuffers. I'm not sure if the compiler would merge
String concatination from concecutive lines, it certainly didn't in my
example above when a loop was involved.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: getRealPath woes

2003-11-04 Thread Tom Parker
On Wed, 2003-11-05 at 12:30, Jim Lynch wrote:

> On the dev. and prod. systems the getRealPath method returns the 
> expected string.  On the testing environment it returns null.

I've found that getRealPath returns null when you are running your
application from a war file without unpacking it. If the file you are
trying to find doesn't exist on the disk, then this is an indication
that you won't be able to get it with getRealPath. 

I guess this is because it is too complicated to patch into all the file
manipulation functions to allow access to the packed contents of the war
file.

getResourceAsStream() works regardless of whether the war file is
unpacked or not.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Form Double Submit Detection

2003-10-28 Thread Tom Parker
On Tue, 2003-10-28 at 23:40, Adam Hardy wrote:

> I don't store the token in the session. When the form submits, I check 
> the session for a hashmap, & if the token is not in the hashmap, I allow 
> the transaction and then put the token in the hashmap.

Interesting. You store the successful tokens so they can't be used
again, and ignore the tokens that are never returned to the server. This
would be more efficient for the case where the user views but never
submits more forms than they view and do submit. I'll have to analyse my
traffic some time and see what my users are doing.

Currently I've implemented the opposite, I keep track of all the tokens
and drop those that the user returns. I also drop all tokens older than
2 hours (which means the user has 2 hours to submit any particular form
before the token goes away and they can't). (and obviously I store them
in the session so they all go away when the session does)

I like your solution better than mine.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: Form Double Submit Detection

2003-10-27 Thread Tom Parker
On Tue, 2003-10-28 at 15:49, Justin Ruthenbeck wrote:

> Here's the situation (correct me if I'm wrong):
>+ User fills out a form and clicks submit
>+ The browser submits the form and sits in a wait state
>+ The server begins processing a request for a new record
>+ The user clicks submit once again
>+ The browser submits the form and sits in a wait state again
>+ The server begins processing a second (identical) request
> 
> This is classic double submission where two requests for the same thing 
> overlap on the server.  Your server thinks they are independent, but you 
> only want one to complete since it's actually a user error.

You understand the situation perfectly.

> And if you're concerned about this affecting your long term memory 
> performance, there are ways to mitigate the impact ... you almost surely 
> don't need this level of guantees for every request.

I did the numbers and found that for our expected workload we couldn't
possibly use more than a couple of megs of memory keeping track of a
unique token for each form served. I'm dropping them after some time (I
haven't decided how long yet, but I think a couple of hours is probably
long enough) which should keep the memory usage under control.

Thanks everyone for your input.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: Form Double Submit Detection

2003-10-27 Thread Tom Parker
On Tue, 2003-10-28 at 14:18, Justin Ruthenbeck wrote:
> At 04:20 PM 10/27/2003, you wrote:
> >On Tue, 2003-10-28 at 12:51, Justin Ruthenbeck wrote:
> >
> > > Server side, instead of putting a token in the session when the page 
> > is
> > > *served*, put a token in the session while the submission is being
> > > processed (use it like a semaphore).  The token has a finite lifecycle
> > > (created on form submission, death on submission response
> > > served).
> >
> >This only works if processing the two submissions overlaps. If the logic
> >to process the submission is very fast, or there is a long delay between
> >submissions, then this won't work.
> 
> 
> I've designed my workflows so that they do not need to store anything in
> the user's session. This allows the user to conduct more than one
> instance of a particular task at the same time without data getting
> mixed up. However this presents me with a problem if the user double
> clicks the submit button and causes the server to do something twice.
> 
> 
> If the logic to process the submission is very fast, then presumably your 
> client would have a response before clicking the submit button again.  If 
> there is a long delay between submissions, then you're dealing with an 
> entirely different problem -- ie not "user double clicks the submit 
> button."

While the logic on the server is reasonably fast, we can't be sure that
the network latency is so low that the user can't double click, nor that
the server will always be fast all the time. In fact we have several
cases of this actually happening and two records being created on the
server.

> If you're truly worried about multiple submissions over long periods of 
> time, then it sounds like your system is more transactional in 
> nature.  That is, the system generates an eligible transaction on one 
> call (form request), then executes that transaction on another (form 
> submit).  In this case, controlling the execution of code should be done 
> on the transaction object level (not request level).

We do have concurrent update checking which catches this problem in most
cases. However that solution does not work when creating a brand new
record. From the server point of view it appears to be two requests to
create a record, which just happen to have the same details (and in this
case we don't want to prevent the user creating apparently duplicate
records, so that isn't a solution).


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: Form Double Submit Detection

2003-10-27 Thread Tom Parker
On Tue, 2003-10-28 at 12:51, Justin Ruthenbeck wrote:

> Server side, instead of putting a token in the session when the page is 
> *served*, put a token in the session while the submission is being 
> processed (use it like a semaphore).  The token has a finite lifecycle 
> (created on form submission, death on submission response 
> served).  

This only works if processing the two submissions overlaps. If the logic
to process the submission is very fast, or there is a long delay between
submissions, then this won't work.



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: Form Double Submit Detection

2003-10-27 Thread Tom Parker
On Tue, 2003-10-28 at 12:26, Bill Lunnon wrote:

> Don't know if this is complimentary to your workflow,
> try a javascript confirm (ie a client side pop-up, asking the user to click
> "Ok" to continue). This will catch any double clicks on the client side.

Unfortunatly I think our users would object to this solution.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Form Double Submit Detection

2003-10-27 Thread Tom Parker
I've designed my workflows so that they do not need to store anything in
the user's session. This allows the user to conduct more than one
instance of a particular task at the same time without data getting
mixed up. However this presents me with a problem if the user double
clicks the submit button and causes the server to do something twice. 

The normal(?) way of detecting this would be to store a unique token in
the session and in the form, and compare them to ensure that the user
has not submitted this form twice. For this to work, you need to store
something in the session for each possible form submission. If the user
never submits the form, then the token will hang around for the life of
the session as we don't know that the user won't submit the form
someday.

Currently I'm thinking of allowing the user to store a finite number of
duplicate check tokens, or to make the tokens expire after an amount of
time. The former doesn't seem very attractive (load a record, view a
bunch of other records such that the first record's token is dropped,
save the first record - no token found), while the latter could lead to
rather a lot of tokens being stored.

Is there a solution to this problem that I'm missing?


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: starting tomcat as non-root

2003-09-03 Thread Tom Parker
On Thu, 2003-09-04 at 13:48, [EMAIL PROTECTED] wrote:

> Hi all.
> I'm o TC4.0.4
> I know this subject has been discussed many times before.
> Are we getting any close to starting tomcat with user "nobody" or
> "tomcat" or anything like that on 8080?
> Sorry for the repetitiveness

su tomcat -c tomcatstartscript

You will need to give the tomcat user write access to the appropriate
directories (the log directory, the webapps directory (if you unpack
wars) and any other work directories) spring to mind. Obviously it will
also have to have read access to a bunch of stuff.

The redhat rpms alraady do this (with the tomcat4 user).

To get such a beast to appear on port 80 I'm using iptables on linux to
forward from port 80 to port 8080 as described at 
http://www.klawitter.de/tomcat80.html


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Need help with performance issue - Tomcat 4.1.X

2003-07-13 Thread Tom Parker
On Sat, 2003-07-12 at 08:08, [EMAIL PROTECTED] wrote:
> We are currently starting up with -Xmx256M.  Java is currently using about 
> 327MB and has been that way for hours.  I haven't really seen any fluxuations 
> at all, which leans me away from the garbage collection issue.

Constant memory usage as viewed by top or other host operating system
commands is normal. The sun 1.4.1 JVM doesn't seem to shrink it's memory
usage. If you've ever used that much memory, it won't be freed just
because you no longer use it all. 

I believe the memory limits are limits that apply to java objects, not
to the overhead of the VM, so the actual memory allocated from the
operating system is always more than what is available to your program
and can be more than the memory limit. I'm only guessing here though.

I would use a network packet sniffer and see if you can isloate what is
going on at the network level. Ethereal is my favourite.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: running tomcat on port 80 instead of port 8080

2003-07-03 Thread Tom Parker
On Fri, 2003-07-04 at 13:16, Neil Zanella wrote:

> Sorry if this is a FAQ but how can I run Jakarta Tomcat on port 80 rather 
> than on port 8080? I guess all I have to do is change 
> $CATALINA_HOME/conf/server.xml so that instead of:

...

Yes, that should work. However if you are running on linux, a normal
user cannot bind to ports below ~1000, you have to be root to do that.
Is it possible to bind Tomcat to port 80 without running the JVM as
root?




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: tomcat/unix security manager questions

2002-08-19 Thread Tom Parker

On Tue, 2002-08-20 at 03:13, Rossen Raykov wrote:

> Unix permissions do take precedence over java security policy.

With a logical AND. If unix permissions say you do have write access,
but the java security policy says you do not, then you do not have write
access, and vice versa. This, of course, assumes that there are no bugs
in the unix or java security policy implementations.


--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




RE: Is there ways to minize the memory used by tomcat ?

2002-07-11 Thread Tom Parker

>   I am developing an application using tomcat. As I put
> development, testing
> and production in the same environment. And each environment has 2
> instances. So there are now altogather 6 instances in the machine. My
> machine is getting slower. Actually, my application is only a
> small one and
> there are only just 20~30 ppl using it. So is there anyway to make tomcat
> eat up less memory ?

As others have said, you should not run production on the same machine as
dev and test.

Are you running 6 different tomcats on 6 different ip addresses or are you
using one tomcat with 6 different web applications at different URL
prefixes?

The latter setup will use less memory than the former.


--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




RE: Tomcat 3.x failures

2002-06-27 Thread Tom Parker

> I have a Tomcat 3.2B6 install on Linux (Debian 2.2), w/ Apache .
>
> The server seems to work fine, but the log files constantly report the
> errors below, about each 4 seconds. after a day or so log files
> of hundreds
> of MB are common.

Did you install the deb from the main Debian archive? I experianced this a
few months ago and solved it by installing the tomcat4 package.

There ought to be a bug in the debian bug tracker that ought to describe
this.


--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




RE: Detect Cookie Rejection

2002-06-03 Thread Tom Parker

> Does anyone know of a way to detect when cookies are not accepted
> by a browser.  My site uses session cookies and I'd like to be
> able to redirect people somewhere to tell them that the site
> requires cookies and what to do to activate them...

If a request comes in with one of your pages as it's referer, but no cookie,
then the browser probably doesn't support cookies, or your cookie expired in
the interval.

Of course, some browsers can be configured to omit the referer header, and I
guess some don't support it at all.


--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




RE: error page is included instead of redirection

2002-05-30 Thread Tom Parker

> if there is a CORBA exception or other during my operations it seems that
> instead of the browser going to error.jsp it is doing an include
> inside the
> page (that is copying the code of error.jsp directly inside).

I believe that this is due to the way redirection works. You can only
redirect a client with a special header. If the headers have already been
sent to the client (because you have written too much data to the output
stream), then you cannot redirect the client anymore. If your error occurs
after the headers have been sent, the only thing that can happen is the
error page is included.

If you do all your processing that can (reasonably) go wrong before writing
any data to the client, any error will cause a redirect, not inclusion.
However if you want commit a heading or some other part of your page before
you do lengthy operations, then you need to structure your error page so
that it looks good when included after the heading or whatever.


--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




Original URL from error page

2002-05-13 Thread Tom Parker

Hi,

I'm trying to get the original URL of the page that caused and exception
from an error page.

http://www.jguru.com/faq/view.jsp?EID=227459

Has a solution and an explanation as to why it does not work. Does anyone
know of a solution?


--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




RE: How can I automatically start a servlet in a specific time?

2002-04-10 Thread Tom Parker

> Can anyone answer my question?
> How can I automatically start a servlet in a specific time? For
> example: at
> midnight.
> I don't want to start it when I start my webserver.

Create an intialisation servlet who's init() method is called when the web
application comes into scope. In the init() method spawn a new thread and
sleep until the apropriate time and then call whatever method you need to
execute at that time. You should be able to set up multiple actions on one
sleeping thread if required. Use a timer object or some other helper to
manage your sleeping.

Be sure also to have a destroy method that shuts down the sleeping thread,
otherwise you thread will keep running when you remove your web application
and the only way to get rid of it will be to restart the whole server.

this code runs periodically, you'll have to do something slightly different
to do something at a particular time of day

   /**
* Called by the container when the application comes into scope (ie on
application load)
*
* Starts the memory logger
*/
   public void init() {
  if (timer != null) {
 WebLogger.log("timer not null aborting MemoryDaemon start");
 return;
  }
  timer = new Timer(true);
  timer.schedule(new DaemonTask(), 0, DELAY_MINS * SECS_MIN *
MILLIS_MIN);
  WebLogger.log("initialised MemoryDaemon");
   }


   /**
* Called by the container when the servlet goes out of scope (ie on
application reload)
*/
   public void destroy() {
  WebLogger.log("Shutting down MemoryDaemon");
  timer.cancel();
   }


--
To unsubscribe:   
For additional commands: 
Troubles with the list: 




RE: j2sdk1.4 compilation errors, any good online source for info?

2002-03-20 Thread Tom Parker

> Thanks for the answer, I'm trying to setup my CLASSPATH to find
> the jar file
> that contains the definition for String.  My problem is that I can't find
> it!!
>
> It used to be in j2ee.jar in j2skee-1_3_01.

You probably shouldn't be using any other definition of java.lang.String
than the one in $JAVA_HOME/jre/lib/rt.jar


--
To unsubscribe:   
For additional commands: 
Troubles with the list: 




RE: Fumbling around Tomcat and Java and XML

2002-02-21 Thread Tom Parker

> I need to add the ability to parse an XML document but have not been
> successful at getting to the right jar files.  What import directive do I
> need to use in my servlet to get access to the DOM parsers
> available in the
> tomcat xerces.jar, or what environment settings do I need to check for
> correctness.

Have a look at the documentation for xalan at http://xml.apache.org this
includes examples and javadocs which will tell you everything you need to
know.


--
To unsubscribe:   
For additional commands: 
Troubles with the list: 




RE: ONE More Time! why does Tomcat 4 work this way

2001-12-06 Thread Tom Parker

> What about  just "/images/butterfly.jpg"? This assumes that your webapp is
> rooted at /bbb -- so you don't need to use that as part of your path. This
> is what I normally use with mod_jk. Don't know if it will work with
> mod_webapp, though.

"./images/butterfly.jpg" would work better.

if you reference ./images from a file in ., then the browser should sort out
the url... Check the access log for the actual URL's that the browser is
requesting.


--
To unsubscribe:   
For additional commands: 
Troubles with the list: 




RE: Huge apache-log in CATALINA_HOME/logs

2001-11-19 Thread Tom Parker


> I´m using Tomcat 4.01 to run .jsp etc. with Apache 1.3.22 as webserver on
> W2K. I´ve been using this combination for about 2 days. Today I
> checked the
> log directory in CATALINA_HOME/logs and found log-file
> "apache_log.2001-11-19.txt" with the enormous size of 175 MB.

Perhaps you might want to look in the log file and post a few lines. With a
log that size, you would expect either your server is 0wned or something is
wrong. The latter case ought to give you a pattern... Post ONE OR TWO cycles
of the pattern, not the whole log.

You've basically said, Tomcat doesn't work, why not? Without providing any
details.


--
To unsubscribe:   
For additional commands: 
Troubles with the list: 




RE: Precompile JSP

2001-11-15 Thread Tom Parker

> Try bin/jspc.bat or jspc.sh

I would like to compile my jsp's as a test before I deploy it and see if it
works. I spend quite a lot of time changing stuff, deploying, loading in a
web browser and seeing jsp compiliation problems.

It would be nice to have jspc compile my jsp's during the deployment
process. I tried this and it seems to recompile everything, rather than only
those files that have changed.

Is there a depends option to jspc?

The obvious solution is to use ant to only compile those files that have
changed, but there doesn't seem to be an equivelent of make's .c.o option in
ant. Is there a dependset creator anywhere, if there isn't a generic .c.o
type task?


--
To unsubscribe:   
For additional commands: 
Troubles with the list: