Java Mailing List Archive

http://www.junlu.com/

Google
Google
Mailing List
Home
Forum Home
JBoss - Java Application Server
Struts - A MVC web framework
Tomcat - JSP/Servlet container
iText - An open source PDF Java Library
JDOM - JDOM XML Parser
J2EE - A mailing list for Java(tm) 2 Platform, Enterprise Edition
J2EE Pattern - An interest list for Sun Java Center J2EE Pattern Catalog
Servlet - A mailing list for discussion about Sun Microsystem's Java Servlet API Technology
JSP - A mailing list about Java Server Pages specification and reference
Struts & Hibernate
Subjects
JSP editor plugin for eclipse ?
org apache jasper JasperException: Unable to compile class for JSP
Tomcat: Connection reset by peer: socket write error
Cannot retrieve definition for form bean null
Struts Tiles Tutorial (free Struts training)
Where do I download Tomcat 4 0 6?
Data Access Object (DAO) pattern, example DAO 's
Where to download Tomcat v 4 1 24 from?
Tomcat 5 0 16 Requested resource not available
Oracle Connection Pooling in 3 2 2
Servlet : Session invalidate
Servlet action is currently unavailable
Tomcat/Struts Unicode Encoding/Decoding problems
Tomcat and webapplication specific java library path
Running a Simple JMS Example
Mapping in workers2 properties
org apache jasper JasperException
Cannot find message resources under key org apache struts action
   MESSAGE
problem with html:text bean throwing exception
Cannot find message resources under key org apache struts action MESSAGE
invalid direct reference problem with solution
Tool for jsp debug Try Sysdeo Eclipse Plugin
Tomcat 5 Cannot load JDBC driver class 'null ' SQL state: null
weblogic ejbc
java properties file
Jboss 3 2 3 Coyote Can 't re
Tomcat 5, Apache2 and mod jk2 integration problem
JBoss example problem new to J2EE
url string for connecting jboss to oracle
Value attribute of <html:checkbox
javax servlet ServletException: BeanUtils populate
HTTP Status 404 The requested resource is not available
5 0 18: Windows XP Pro vs Windows 2000
 
response.reset() and forward() ... problematic? DBCP related?

response.reset() and forward() ... problematic? DBCP related?

2003-12-10       - By Anthony Presley

 Back
Reply:     1     2     3     4     5     6     7     8     9     10     >>  

Hi all,

Decided to move my discussion from Commons to Tomcat, as the
bug-tracking process appears that this is a more relevant place to post.

I'm not using a MVC implementation (ala Struts), but I do have about
100K lines of servlets and JSP's, and I'm having a lot of errors, which
scale based on the number of users.  For instance, assuming I have
around 10 people working on the system, I will have no errors.  As that
number scales, it becomes a huge problem, and lots of error's start
showing up.  I've tracked down and squashed most of the DB errors, but
am left with the following quandry:

I'm not storing any data in the session, and use forward() ... a lot.
When the following code executes, and I only open one request (ie, I
click on the link to open a new window which fetches a servlet
response), it works flawlessly.  When I click more than once, I start
getting forward() errors.

Here's some code snippets:

 protected void forward(String s) {
     ServletConfig sc = null;
     ServletContext sContext = null;
     RequestDispatcher rd = null;
     
     try {
       sc = this.getServletConfig();
     } catch (Exception e) {
       log("2ERROR Exception: " + e.getMessage());
       e.printStackTrace();
     }
     
     try {
       sContext = sc.getServletContext();
     } catch (Exception e) {
       log("3ERROR Exception: " + e.getMessage());
       e.printStackTrace();
     }
     
     try {
       rd = sContext.getRequestDispatcher(s);
     } catch (Exception e) {
       log("4ERROR Exception: " + e.getMessage());
       e.printStackTrace();
     }
     
     try {
       log ("Buffer size is: " + res.getBufferSize());    
       
       if (rd != null)
         rd.forward(req, res);
       else {
         log("RD is NULL, MAJOR ERROR");
       }
     } catch (ServletException e) {
       log("5ERROR ServletException: " + e.getMessage());
       e.printStackTrace();
     } catch (java.io.IOException Source code of java.io.IOException e) {
       log("5ERROR java.io.IOException Source code of java.io.IOException: " + e.getMessage());
       e.printStackTrace();
     } catch (Exception e) {
       log("5ERROR Exception: " + e.getMessage());
       e.printStackTrace();
     }
 }

I will get an error "5ERROR ServletException: Cannot forward after
response has been committed".

This error is generated when the following conditions exist:

1.  More than one user is trying to pull the same information.  For
instance, if I open three windows, each requesting the same info, two of
them will likely error.  With twenty requests, I get about sixteen
errors [consistently].

2.  More than one user trying to pull different information.  Although
the error is almost certain to happen when more than one user pulls the
same data, pulling different data (simulated with multiple windows),
gets me the same error, at about the same frequency.

2.  Rerequesting the error'd page will get me the correct output (no
changes made to the data or JSP / servlets).  <IE, I'm not forwarding
twice, nor am I printing the buffer before I should [below]>

3.  I've bumped the response buffer (in the servlet) from 8K to 75K
(75000), which reduces the errors, but they are still present.  Is there
a GOOD way to estimate the amount needed?

4.  Using DBCP 1.0 .... using the latest DBCP (1.1?), seems to reduce
the errors further (1 in 10, approx).  I've rewritten the code to ensure
that connections are being opened / closed locally, and quickly.  Timing
it shows that the DB connection is pulled from the pool for about 2300
milli, and the JSP runs for about 2 milli to display.

I'm not 100% sure yet if the problem persists in the JSP (using a simple
JSP and simple servlet does not cause these problems, however, the
greater the complexity, the higher the likelihood of getting these
errors .... which baffle's me, because rerequesting it shows up fine,
with nothing in the logs) or the servlet.

Anyone seen this before?  I'm about at my wits end.  Been refactoring
for a week now, and still it persists.

-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ------
To unsubscribe, e-mail: tomcat-user-unsubscribe@(protected)
For additional commands, e-mail: tomcat-user-help@(protected)




©2008 junlu.com - Jax Systems, LLC, U.S.A.