File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Extremely slow initial servlet access Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Extremely slow initial servlet access" Watch "Extremely slow initial servlet access" New topic
Author

Extremely slow initial servlet access

Michael Crutcher
Ranch Hand

Joined: Feb 18, 2002
Posts: 48
I've got a strange problem with a webapp that I've created and was hoping someone might be able to point me in the right direction. My webapp requires password authentication for any attempted access to a jsp page. The login page (an html file) pulls up very quickly, but after submitting the form the next jsp page takes forever (20-40 secs) to come up. The wierd thing is that it only takes this long from some computers and not others. I've cleared the cache in my browser, but am still able to advance from the login page in under a second. From my bosses computer, even without clearing the cache, it takes 20-40 secs just to come up.
I'm pretty stumped, I don't know what is causing this strange behaviour. Even stranger, the other computers in the office that are taking so long to access the page have in the previous few weeks accessed jsp's from the login extremely snappy.
Any ideas? Any guesses?
Thanks,
Michael Crutcher
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12786
    
    5
Sounds like time to put some diagnostic statements in to find out what part of the JSP takes so long. One would naturally suspect any database query related to the authentication. You might look into this monitoring tool:
The JAMon monitoring tool.
Michael Crutcher
Ranch Hand

Joined: Feb 18, 2002
Posts: 48
More wierdness:
I was going to time all of the calls the page is making (its dynamically filling list boxes from a bean), but decided that I'd take down the password authentication to see if that had anything to do with it.
It seems like it does, with password authentication turned off it takes the expected amount of time to pull the jsp up (1 sec compiled, 2-3 seconds when compiling for the first time). The wierd thing (besides the fact that the login page is increasing load time for the jsp by 40 secs or so) is that with authentication turned off about %50 of users cannot see the page at all. Tomcat returns a resource not available error for the jsp.
Any ideas? It just seems uber-wacky to me.
Thanks,
Michael Crutcher
Michael Crutcher
Ranch Hand

Joined: Feb 18, 2002
Posts: 48
I'm using form based authentication with tomcat. The relevant stuff to authentication is detailed below:
In the web.xml file associated with the web application in question:
<security-constraint>
<web-resource-collection>
<web-resource-name>WebQuery</web-resource-name>
<url-pattern>*.jsp</url-pattern>
<http-method>DELETE</http-method>
<http-method>GET</http-method>
<http-method>POST</http-method>
<http-method>PUT</http-method>
</web-resource-collection>
<auth-constraint>
<role-name>query</role-name>
<role-name>admin</role-name>
</auth-constraint>
</security-constraint>
<login-config>
<auth-method>FORM</auth-method>
<form-login-config>
<form-login-page>/login.html</form-login-page>
<form-error-page>/login_error.html</form-error-page>
</form-login-config>
</login-config>
The login page:
<html>
<head>
<title>WebQuery Login Page</title>
</head>
<body>
<form method="POST" action='j_security_check'>
<table width="100%" border="0">
<tr>
<td>
<div align="center"><img src="financial_reports.gif" width="600"
height="81" alt="Financial Summary Reports"><br>
<br>
<table width="587" border="0" class="tblbrdr" cellpadding="4"
cellspacing="0">
<tr>
<td width="27%"> <b>Username:</b></td>
<td colspan="2" width="73%"><input type="text"
name="j_username"></td>
</tr>
<tr>
<td width="27%"> <b>Password:</b></td>
<td colspan="2" width="73%"><input type="password"
name="j_password"></td>
</tr>
<tr>
<table width="587" border="0">
<tr>
<td>
<input type="submit" value="Login Now">
</td>
</tr>
</table>
</div>
</td>
</tr>
</table>
</FORM>
</body>
</html>
tomcat-users.xml:
<tomcat-users>
<user name="mcrutcher" password="****" roles="admin"/>
</tomcat-users>
I think that this stuff is ok, but if you find anything let me know. If you want me to post the full code of the rest of the webapp I will, but I'm fairly convinced that something really wacky is going on with the authentication. I'm using Tomcat 4.0.
This problem just seemed to appear out of thin air. One day everyone was accessing the page with reasonable load times, the next day this wierdness showed up. I'm really dead in the water until I figure this out, I'd really appreciate any help.
Michael Crutcher
Comment from mcrutcher
04/16/2003 10:30AM PST
I'm using form based authentication with tomcat. The relevant stuff to authentication is detailed below:
In the web.xml file associated with the web application in question:
<security-constraint>
<web-resource-collection>
<web-resource-name>WebQuery</web-resource-name>
<url-pattern>*.jsp</url-pattern>
<http-method>DELETE</http-method>
<http-method>GET</http-method>
<http-method>POST</http-method>
<http-method>PUT</http-method>
</web-resource-collection>
<auth-constraint>
<role-name>query</role-name>
<role-name>admin</role-name>
</auth-constraint>
</security-constraint>
<login-config>
<auth-method>FORM</auth-method>
<form-login-config>
<form-login-page>/login.html</form-login-page>
<form-error-page>/login_error.html</form-error-page>
</form-login-config>
</login-config>
The login page:
<html>
<head>
<title>WebQuery Login Page</title>
</head>
<body>
<form method="POST" action='j_security_check'>
<table width="100%" border="0">
<tr>
<td>
<div align="center"><img src="financial_reports.gif" width="600"
height="81" alt="Financial Summary Reports"><br>
<br>
<table width="587" border="0" class="tblbrdr" cellpadding="4"
cellspacing="0">
<tr>
<td width="27%"> <b>Username:</b></td>
<td colspan="2" width="73%"><input type="text"
name="j_username"></td>
</tr>
<tr>
<td width="27%"> <b>Password:</b></td>
<td colspan="2" width="73%"><input type="password"
name="j_password"></td>
</tr>
<tr>
<table width="587" border="0">
<tr>
<td>
<input type="submit" value="Login Now">
</td>
</tr>
</table>
</div>
</td>
</tr>
</table>
</FORM>
</body>
</html>
tomcat-users.xml:
<tomcat-users>
<user name="mcrutcher" password="****" roles="admin"/>
</tomcat-users>
I think that this stuff is ok, but if you find anything let me know. If you want me to post the full code of the rest of the webapp I will, but I'm fairly convinced that something really wacky is going on with the authentication. I'm using Tomcat 4.0.
This problem just seemed to appear out of thin air. One day everyone was accessing the page with reasonable load times, the next day this wierdness showed up. I'm really dead in the water until I figure this out, I'd really appreciate any help.
Michael Crutcher
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Extremely slow initial servlet access