Re: [OT] JDBC confusion

2003-08-07 Thread Andrew Geery
The preferred way of doing this is to use connection pooling. The 
primary reasons are scalability, speed and simplicity. If you have 5,000 
people using your app at the same time, by your method you will have to 
have 5,000 connections to the database (one per user) stored in the 
various sessions. However, those 5,000 connections aren't being used at 
the same time: each one probably has only an infrequent burst of 
activity on it. This is where connection pooling comes in. The 
connection pool has n connections (say, 10 - 20) that are kept active. 
When an application needs a connection to the database, it checks one 
out from the pool (it doesn't need to create and open one because it is 
already created and open -- a win in terms of speed), uses it and closes 
it just any other database connection. However, when it closes the 
connection, the connection isn't really closed; it's just returned to 
the pool. So, the application developer is hidden from the complexity of 
actually creating the connections to the database, making sure they are 
in good working order, etc.

To get started with connection pooling in Tomcat, see 
http://jakarta.apache.org/tomcat/tomcat-4.1-doc/jndi-datasource-examples-howto.html

And check out the mailing list archives: the question of setting up 
connection pooling comes up very frequently.

HTH
Andrew
P.S. Depending on the size/complexity of your project, you might be 
better off using an O/R mapping tool like OJB 
(http://db.apache.org/ojb/) or Hibernate 
(http://hibernate.bluemars.net/) instead of using JDBC directly.

john-paul delaney wrote:

Hello List... newbie question coming up:

If I set up a jdbc connection object in one servlet, do I have to close it each time or can the same connection be re-utilized by other servlets each using a different sql statement (perhaps storing the connection as a session attribute?).

Is there a significant resource saving by not creating a JDBC connection object for each database access?

I'm thinking of storing a connection for each user in the session, as opposed to pooling - primarily because I'm not sure how a database pool works nor how to set it up.  Should I do a re-think on this?

I'm using one postgresql 7.3.3

thanks
/j-p.
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



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


Re: Tomcat with Virtual hosting

2003-07-30 Thread Andrew Geery
Why do you need to forward the request from index.html to index.jsp? 
Can't you simply set index.jsp to be a directory index page (e.g., 
DirectoryIndex index.html index.jsp)?

Abhinav Gautam wrote:

Hi,

I am having serious problems with Tomcat. It just happened that without
any reason the web server stopped responding to JSP requests. I have
restarted Tomcat and Apache several times, but when the index.html
forwards the request to index.jsp, I get an error saying page not found.
I have checked the server.xml and the httpd.conf files and everything
seems to be fine. Also when I do netstat -ta the server seems to be
listening on port 8007.
I have virtual hosting set up in tomcat. There's one primary domain with
an IP address and there are 2 other domains with a different IP (different
from primary, but one IP for both of the other domains) set up on the same
web server.
Any help will be greatly appreciated.

Thanks.
Abhinav




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



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


Re: tomcat5.0

2003-07-29 Thread Andrew Geery
WEB-INF has a special meaning to a servlet container (e.g., Tomcat) and 
must be a top-level directory in your web application directory (in this 
case, it must be located at .../ROOT/WEB-INF).

Download the servlet specification and take a look at section 9.5: 
http://java.sun.com/products/servlet/download.html

Raicea Lavinia wrote:

Hi,
  My name is Lavinia Raicea and I am a student. I am trying to learn
about JSP2.0 and Servlets so I have installed Apache Tomcat 5.0 (Windows
XP) and I took some documentation to run some servlet examples.
  I don't know what I am doing wrong but when I put the source code in
the folder $installdir/webapps/ROOT/WEB-INF/classes it works. But when I
do the same thing but in a subfolder of ROOT
(.../ROOT/deploy/WEB-INF/classes) it doesn't work anymore.I think is
something with my configuration of tomcat but I dont't seem to get it
right.
 If you would be so kind and tell me where I am wrong I would be very
grateful.
   Thank you very much,
Lavinia


-
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
 



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


Re: Tomcat Education Examples

2003-07-29 Thread Andrew Geery
I think what you're looking for is an application framework. There are 
a number of them at Apache:

Struts: http://jakarta.apache.org/struts/index.html
Turbine: http://jakarta.apache.org/turbine/index.html
Tapestry: http://jakarta.apache.org/tapestry/index.html
Cocoon: http://cocoon.apache.org/
Jetspeed: http://jakarta.apache.org/jetspeed/site/index.html
All of the above projects have nice example templates.

Donald Duquaine wrote:

I understand that this list can be helpful to have our questions answered.
And, that
books seem not to be the most up todate means to acquire the most current
practices
and Tomcat (catalina) techniques.  I learn best by examples and I have been
a Tomcat
user for several years.  In all my google searching, I have not found a
robust template
example that has assisted me in creating my app.  I am having to code from
scratch.
I have started over several times because my design was flawed for one
reason or another,
but I am making headway.  My app is now in production. What I want most is
to be
part of a group that is focused on developing the end application.  Tomcat
is an important
part of this development and this 'app-group' would need to recognize
Tomcat's capabilities.
How many others need an 'app-group'? or examples?
Best Regards,

Donald Duquaine
Millennium Laboratories Inc.
(813) 925-3871 voice (813) 925-3872 fax
mailto:[EMAIL PROTECTED]
http://www.mlabs-fl.com
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



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


RE: Tomcat Realm Example Problems

2002-11-20 Thread Andrew Geery
This error means that you directly referenced the login page. This is an
annoyance with Tomcat security realms: you get authenticated, but since you
weren't going anywhere in the realm, you get the HTTP Status 400 error.
Rather than accessing the login page, simply access any page that is
protected by the realm. Tomcat will bounce you to the login page and,
following successful authentication, will bounce you to the page you were
originally trying to access.

Andrew

-Original Message-
From: Brown, Melonie S. - Contractor
[mailto:[EMAIL PROTECTED]]
Sent: Wednesday, November 20, 2002 12:04 PM
To: [EMAIL PROTECTED]
Subject: Tomcat Realm Example Problems


Running Tomcat 4.1.12 on Windows 2K...

I try running the jsp security realm example and get the following error
after logging in:

HTTP Status 400 - Invalid direct reference to form login page
type Status report
message Invalid direct reference to form login page
description The request sent by the client was syntactically incorrect
(Invalid direct reference to form login page).

Any suggestions?  This is from the example code provided.  I have made no
changes.

Melonie Brown



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

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




RE: Getting 4.0.4

2002-11-19 Thread Andrew Geery
See
http://jakarta.apache.org/builds/jakarta-tomcat-4.0/archives/
for past versions of Tomcat.

Be aware, though, that Tomcat 4.0.4 and 4.0.5 have security vulnerabilities.
See
http://jakarta.apache.org/site/news.html
for 9Oct2002 and 24Sep2002 for more information.

Andrew

-Original Message-
From: Andoni [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, November 19, 2002 5:53 AM
To: Tomcat Users List
Subject: Getting 4.0.4


Hello,

I work with OpenVMS and as such I want  to work with the exact version of
Tomcat for my Win2k workstation that I am using on the live server.  Is
there any way I can download Tomcat 4.0.4 (instead of 4.0.6) from the tomcat
site?

Thanks,

Andoni.


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

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




RE: Page caching in 4.0.x

2002-11-18 Thread Andrew Geery
I'm having a similar problem (also using struts) in Tomcat  4.0.2.

Scenario: I have a search page that performs a search and brings up a
results page. On the results page, you can click on a hyperlink to get
additional information about an element of the search. If you have clicked
on a hyperlink and are on the page with the additional information about an
element of the search and you click the back button of the browser, you get
the message [in IE] Warning: Page has expired.

I've found that the problem (for me) is realm security. Using the JDBCRealm,
I get the above message when I use the back button; however, if I modify the
realm such that it is not protecting my search and results pages, I no
longer receive the warning when I use the back button.

I'm guessing that the realm filter turns caching off for all pages in the
realm. Watching the access logs, I've noticed that even for jsp pages in a
realms, the browser goes back to the server and reloads the page, rather
than using a cached copy of the page (as it does for pages not in the
realm).

Does that sound correct? Is there some way to disable turning the caching
off?

Thanks
Andrew

-Original Message-
From: Eric Hansen [mailto:[EMAIL PROTECTED]]
Sent: Friday, November 08, 2002 11:36 AM
To: Tomcat Users List
Subject: Page caching in 4.0.x


Hello, 
I'm in the process of migrating a Struts-based web application from Tomcat
3.x to Tomcat 4.0.6.

Without making any changes to the 'Action' servlets or the JSP pages, my
form based pages are now giving the 'Page has Expired' message and forcing
me to 'refresh'.  They never did this with Tomcat 3.x

My JSP pages have no expire dates set in the header nor any other header
directives relating to caching (that I am aware of)

Can anyone venture an explanation to this change?  and maybe a solution...

Thanks,
Eric Hansen

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




TC authentication: j_security_check and url-pattern

2002-11-15 Thread Andrew Geery
I'm using form-based authentication in Tomcat 4.1.12 -- it works great!

However, I have two questions about Tomcat authentication:

1) Many end-users bookmark the login page. So, the first time they login
everything works as expected, but when they use the bookmark, they get the
invalid reference form login page. Is there a way to specify a page for
Tomcat to redirect the user to after authentication in the case that the
user goes directly to the login page? I've seen this question come up in the
archives, but I haven't seen a solution other than user education :). The
closest thing I've seen is 
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=8976
Does anyone know the status of this enhancement? Is there some other
workaround?

2) I have some images I want to use on the login page. If I use
url-pattern/*/url-pattern in the web.xml file, the pictures are blocked
from being displayed. In the web.xml file, I would like to say, 'protect all
files except the images used on the login page'. Is there a way to do this;
that is, rather than saying, 'protect x, y and z', is it possible to say,
'protect everything except a, b and c'? I haven't seen anything like this in
the documentation.

Thanks
Andrew



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




RE: Pager Tag Library - Broken in 4.1.12

2002-11-08 Thread Andrew Geery
See the following thread which explains why the problem arises and how to
fix it.

http://www.mail-archive.com/tomcat-user;jakarta.apache.org/msg67093.html

To the above solution, I made two additional changes because
1) the list of duplicated parameters on the url grew as it was paged -- e.g.
url?a=ba=ba=ba=b... (I was using the pg:param tag) 
2) after paging in list1 and going to list2 where I expected to begin paging
on the first page, I would begin paging on the page number of list1.

The modified method for the com.jsptags.navigation.pager.PagerTag class is
below.

HTH
Andrew




public int doStartTag() throws JspException {
if (url == null) {
url = ((HttpServletRequest)pageContext.getRequest())
.getRequestURI();
int i = url.indexOf('?');
if (i != -1)
url = url.substring(0, i);
}
System.out.println(url =  + url);

itemCount = 0; // modified
params = null; // modified
offset = 0; //modified
String tmp =
pageContext.getRequest().getParameter(id+OFFSET_PARAM);
if (tmp != null) {
try {
offset = Integer.parseInt(tmp);
if (offset  0)
offset = 0;
if (isOffset)
itemCount = offset;

} catch (NumberFormatException e) {
}
}

pageNumber = pageNumber(offset);
pageNumberInteger = new Integer(1+pageNumber);

pageContext.setAttribute(id+PAGE_NUMBER, pageNumberInteger);
pageContext.setAttribute(id+OFFSET, new Integer(offset));
pageContext.setAttribute(id+MAX_ITEMS, new
Integer(maxItems));

return EVAL_BODY_INCLUDE;
}

-Original Message-
From: Robert Biernat [mailto:RobertB;oopl.com.au]
Sent: Friday, November 08, 2002 2:54 AM
To: '[EMAIL PROTECTED]'
Subject: Pager Tag Library - Broken in 4.1.12


Hi,
 
I'm trying to use the Pager Tag Library found at
 
http://jsptags.com/tags/navigation/pager/pager-taglib-1.1.html
http://jsptags.com/tags/navigation/pager/pager-taglib-1.1.html 
 
in my webapp thats running on 4.1.12 and it appears that 4.1.12 has
something in it which prevents the tag from working correctly. Basically
when the page is first rendered it looks fine, until you try and page
through the records in which case it doesnt work. 
 
Whats even worse is even after closing the browser and going back to the
page, instyead of the tag rendering correctly it stays in the samne state it
was at before the broswer was closed. Its as if the tag lib is being cached
somewhere.
 
Does anyone know wether 4.1.12 introduced anything that new that could be
causing it.
 
Also in this new version I sometimes get jasper exceptions after I redeploy
an application, but this goes away usually if i jhust hit refresh in the
browser.
 
I tested it in Tomcat 4.0.X and it works fine. 
 
Has anyone else experienced this problem?
 
Thanks
 
Rob

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