Re: how not to run servlet as root

2002-03-10 Thread Mark Himsley

Include something like the following in a startup script. This I run as root
and you can see that it changes user to 'httpd' (the user my web server runs
under) and then starts catalina. It works very well, at least for me.

su - httpd -c $CATALINA_HOME/bin/catalina.sh start

Good luck.


On Fri, 8 Mar 2002 14:50:03 -0500 you wrote:

I am trying out Tomcat with apache on linux.
I would like the servlets NOT to run as root.  Where can I find the
instruction how to run servlets without privilege?  I suppose this means,
how to run tomcat on an ordinary user account or as nobody?

Thank you very much,

yako sanborn
[EMAIL PROTECTED]

-- 
Mark Himsley
In Acton

--
To unsubscribe:   mailto:[EMAIL PROTECTED]
For additional commands: mailto:[EMAIL PROTECTED]
Troubles with the list: mailto:[EMAIL PROTECTED]




Apache sending Redirect when DirectoryIndex is index.jsp

2001-09-20 Thread Mark Himsley

Hi all,

I have asked this question previously but I still can't work it out. I've
checked through my archives of this list but failed to find the
answer.

I have Apache 1.3.x serving static content and Tomcat 3.2.3 serving JSP
and servlets using ajpv12 as the link between the two.

Everything is working fine, except for one small point. I have the
DirectoryIndex set thus:

DirectoryIndex index.html index.shtml index.jsp

and I'm pushing JSP through Tomcat with:

AddType text/jsp .jsp
AddHandler jserv-servlet .jsp

This is fine, except if a directory index file is a JSP.

Lets say that the first file in a web site is /index.jsp. The client
browser sends GET / HTTP/1.1. In this case the server replies HTTP/1.1
302 Found with a redirect Location of /index.jsp. This forces the client
to make a second request, this time GET /index.jsp HTTP/1.1 and makes
the client's browser display the URL including the index.jsp.

This is not only bandwidth inefficient and ugly, but could cause problems
in the future. If the user bookmarks this page (it's a really good site
:-) and I go and change the first page from being index.jsp to index.html
then the users bookmark will be broken. I always thought that this was the
point of hiding the DirectoryIndex filename.

Could someone tell me how to 'hide' this 302 redirect, the way Apache does
for index.html and index.shtml (and any other file listed in
DirectoryIndex)?

Many thanks.

--
Mark Himsley
In Acton



Re: Get value from a checkbox

2001-09-17 Thread Mark Himsley

On Mon, 17 Sep 2001 07:32:38 +0200 you wrote:

Hi! I'm a newbi on jsp, and having trouble with forms.

I have a form on one page and want to send the information to a jsp page. My form 
includes a couple of checkboxes and I only gets runtime errors when I try to get the 
values from the checkbox.

Fact is I dont have a clue how to get the value from a checkbox in jsp with the 
request.getParameter.

This is very basic. I suggest you get a book on HTML, HTTP and
JSP/Servlets, but lets see if I can help with this specific problem.

If an HTML form is submitted with an unchecked check box then that
parameter is not even returned to the server. Therefor you have to check
that the parameters exists or not:

if (request.getParameter(checkbox) != null) { /* checkbox checked */ }

What I often do is:

1) create the checkboxes with a value of 1

input type=checkbox name=checkbox value=1

2) write a bean to accept all the request parameters. If you declare the
   instance variables initially equalling false:

boolean checkbox = false;

   and create a setter method which sets the value of this instance
   variable

public void setCheckbox(int value) {
checkbox = true;
}

3) all you need to so then is 

jsp:useBean id=form scope=request class=your.bean/
jsp:setProperty name=form property=*/

4) now all your form request parameters are stored in the bean and you
also do not need to do any checking for null's because you created default
values for all of your request parameters.

--
Mark Himsley
In Acton



Apache sending Redirect when DirectoryIndex is index.jsp

2001-09-15 Thread Mark Himsley

Hi,

I've checked through my archives of this list but failed to find the
answer.

I have Apache 1.3.x serving static content and Tomcat 3.2.3 serving JSP
and servlets using ajpv12 as the link between the two.

Everything is working fine, except for one small point. I have the
DirectoryIndex set thus:

DirectoryIndex index.html index.shtml index.jsp

and I'm pushing JSP through Tomcat with:

AddType text/jsp .jsp
AddHandler jserv-servlet .jsp

This is fine, except if a directory index file is a JSP.

Lets say that the first file in a web site is /index.jsp. The client
browser sends GET / HTTP/1.1. In this case the server replies HTTP/1.1
302 Found with a redirect Location of /index.jsp. This forces the client
to make a second request, this time GET /index.jsp HTTP/1.1 and makes
the client's browser display the URL including the index.jsp.

This is not only bandwidth inefficient and ugly, but could cause problems
in the future. If the user bookmarks this page (it's a really good site
:-) and I go and change the first page from being index.jsp to index.html
then the users bookmark will be broken. I always thought that this was the
point of hiding the DirectoryIndex filename.

Could someone tell me how to 'hide' this 302 redirect, the way Apache does
for index.html and index.shtml (and any other file listed in
DirectoryIndex)?

Many thanks in advance.

--
Mark Himsley
In Acton



Number of threads running

2001-06-07 Thread Mark Himsley

Hi,

I'm running tomcat 3.2.2 connecting through Apache using AJP12 on RedHat
6.2 with jdk1.3.1 and not much memory (a development system).

I am wondering about the number of threads I see running - looking at the
output of `ps aux` I can see 18 threads. I have two connectors setup, an
HttpConnectionHandler with Parameter name=max_threads value=2/ and
an Ajp12ConnectionHandler with Parameter name=max_threads value=5/.

I'm just wondering why there are an extra 11 threads, and what they might
be doing (and yes I do know I could dump the HttpConnectionHandler but
occasionally it is useful to check that Apache and Tomcat are setup
correctly).

Thanks.

--
Mark Himsley
In Acton