J You

Greenhorn
+ Follow
since Jul 31, 2001
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by J You

One of my big fear as developer is to have a "geek" style "procedure" which so focuses on "Object Oriented under whatever circumstances" that it will "Over-OO" everything.
I agree with above comment.
I'd say Modeling, OOD, Design Pattern etc are all GOOD things...they all look extremely RIGHT in textbook, but in reality I don't think they really help us that much (sure I am talking from my own experience)
If we have a lot of time to kill, I'd like to spend some time on the diagrams and documents - it doesn't help the coding, but makes me "feel good" ...But most time, we are in tight skedule, and most pain come in the second half of the process, and most time are not spent on coding, but "communication", not with your fellow programmers, but with clients, business managers, DBA, migration team, testing team ....
I am developing a server application, which has to query another server to get the info it needs. So, in my Servlet program, first I send request to the remote URL through HttpURLConnection.The code is like following:
String strURL = "...";
try{
URL url = new URL(strURL);
conn = (HttpURLConnection)url.openConnection();
if(conn!=null){
reader = new BufferedReader(new
InputStreamReader(conn.getInputStream()));
while((line = reader.readLine())!=null){
//process the line
}
}

}
}catch(Exception e){
//do nothing
}finally{
if(reader!=null)
reader.close();
if(conn!=null)
conn.disconnect();
}
This approach works, but I found it is pretty slow. Most of time is spent on the statement to get the BufferedReader...
Any advice?
Thanks.
here is the change I made to the Tomcat/conf/server.xml
1, comment the mbean, because I use mod_jk, and got errors if the mbean is not commented.
<!-- <Listener className="org.apache.catalina.mbeans.ServerLifecycleListener"
debug="0"/>
<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener"
debug="0"/>
-->
2, open the non-ssl coyote http listener
<Connector className="org.apache.coyote.tomcat4.CoyoteConnector"
port="9990" minProcessors="5" maxProcessors="75"
enableLookups="true" redirectPort="8443"
acceptCount="100" debug="0" connectionTimeout="20000"
useURIValidationHack="false" disableUploadTimeout="true" />
3, comment the coyote/jk2 listener and open the
jk AJP13 listener
<Connector className="org.apache.ajp.tomcat4.Ajp13Connector"
port="11009" minProcessors="5" maxProcessors="75"
acceptCount="10" debug="0"/>
4, create the context path of my web application.
15 years ago
here is the conf/workers.properties file:
#work properties
ps=/
worker.list=tomcat1,tomcat2,loadbalancer
worker.tomcat1.port=11009
worker.tomcat1.host=localhost
worker.tomcat1.type=ajp13
#worker.tomcat1.cachesize
worker.tomcat1.lbfactor=1
worker.tomcat2.port=12009
worker.tomcat2.host=localhost
worker.tomcat2.type=ajp13
#worker.tomcat2.cachesize
worker.tomcat2.lbfactor=1
worker.loadbalancer.type=lb
worker.loadbalancer.balanced_workers=tomcat1,tomcat2
15 years ago
here is the part of httpd.conf:
# load module JK
LoadModule jk_module libexec/mod_jk-1.3-noeapi.so
JKWorkersFile conf/workers.properties
JKLogFile logs/mod_jk.log
JKLogLevel info
JkRequestLogFormat "%w %q %V %v %p %s %T"
....
DocumentRoot "/opt/Apache1.3.27/htdocs"
JKMount /*.jsp loadbalancer
JKMount /servlet/* loadbalancer
JKMount /myapplication/* loadbalancer
15 years ago
Hi,
In our Solaris(SunOS5.6) system, I installed the Apache 1.3.27, mod_jk_1.3_no_eapi.so, and 2 copies
of Tomcat 4.1.8. The apache will act as frontend
and dispatch requests to the 2 instances of Tomcat.
There is no error shown when I configure,install
and run the servers.
I also use the Grinder as stress test tool:http://grinder.sourceforge.net/
To test the system, I changed the Tomcat1, Tomcat2 http listening port to 9990,9991,
the Apache is listening at 2947, the mod_jk
ports are 11009, and 12009.
From the server.xml, it seems the Tomcat can serve at most 75 concurrent requests. From httd.conf, the Apache can serve 175 requests.
I placed a very simple JSP file in the web application root, and wrote a grinder test script
which sends 70 requests in very short time.
Here is the testing results:
1, if I use the grinder to send requests directly
to Tomcat, the mean response time is about 600ms
2, if I use the grinder to send requests to Apache, the mean response time becomes pretty big,
like 4s. this result is really weired.
I then checked the Tomcat log, it seems all 70 requests were dispatched to Tomcat1, which I guess
is normal since the limit of Tomcat1 is 75.
But in the Apache/logs/mod_jk.log, there were some
error messages like
Fri Jan 10 08:45:01 2003] loadbalancer
my.com my.com 2947 200 0.167065
[Fri Jan 10 08:45:01 2003] loadbalancer my.com my.com 2947 200 0.116934
[Fri Jan 10 08:45:01 2003] loadbalancer my.com my.com 2947 200 0.146300
[Fri Jan 10 08:45:01 2003] [jk_ajp_common.c (681)]: ERROR: can't receive the response message from tomcat, network problems or tomcat is down.
[Fri Jan 10 08:45:01 2003] [jk_ajp_common.c (1050)]: Error reading reply from tomcat. Tomcat is down or network problems.
[Fri Jan 10 08:45:01 2003] [jk_ajp_common.c (1187)]: ERROR: Receiving from tomcat failed, recoverable operation. err=0
[Fri Jan 10 08:45:01 2003] [jk_ajp_common.c (681)]: ERROR: can't receive the response message from tomcat, network problems or tomcat is down.
[Fri Jan 10 08:45:01 2003] [jk_ajp_common.c (1050)]: Error reading reply from tomcat. Tomcat is down or network problems.
[Fri Jan 10 08:45:01 2003] [jk_ajp_common.c (1187)]: ERROR: Receiving from tomcat failed, recoverable operation. err=0
[Fri Jan 10 08:45:01 2003] loadbalancer my.com my.com 2947 200 0.117587
[Fri Jan 10 08:45:01 2003] loadbalancer my.com my.com 2947 200 0.125157
[Fri Jan 10 08:45:01 2003] loadbalancer my.com my.com 2947 200 0.122595
This errors shows that the communication between Apache(mod_jk) and Tomcat got trouble randomly.
I also made another tests which sent 100 requests to Apache, and from the tomcat log, it seems this
time the Tomcat2 got some hits.
From my testing, I feel the mod_jk did work, as load balancer, to dispatch requests to multi tomcat instances.But the whole performance is bad
because of the error shown in mod_jk.log.
I will post the httpd.conf, server.xml, workers.properties files in following posts.
Any advice is greatly appreciated!
15 years ago
We have the weblogic5.1 SP8, it connects to Oracle8.1.7.
When I test the addBatch method, it
gives error like:
weblogic.jdbc.pool.Statement.addBatch abstract method.
I checked the weblogic API, and can not find the
addBatch method in weblogic.jdbc.pool.Statement,
while there is one in weblogic6.0 API.
So, I guess, to use the batch updates, we either
have to update to weblogic 6.0, or we use standard
JDBC connections instead of the connection from
Weblogic connection pool.
Any advice is greatly appreciated!
15 years ago
I have this web application running on weblogic 5.1 SP8, with Oracle server 8.1.7.
To use the batch updates feathure of JDBC2.0, I upload the classes12.zip to the server, and changed the startWebLogic.sh to replace the classes111.zip
with classes12.zip in java class path.
But, when my program call the statement.addBatch, it gave the following error:
java.lang.AbstractMethodError: weblogic/jdbc/pool/Statement.addBatch
Seems the jdbc driver doesn't support this method.
To confirm it, I called the driver.getMajorVersion and it returned 1.
Can anyone tell me
how to make the weblogic support the JDBC2.0?
Thanks.
15 years ago
We have the application with a typical login
page, and once the user logs on, some user
data will be saved in session attributes.
Now, I was asked to add such a feathure:the user
only want to login for one time every day.The
other times the user can go directly to the menu,
even after "close and then restart the browser".
I set the session time-out variable to be a
pretty big number.I found once the browser
is closed, the session is still alive(getSession(false)!=null),
but the session attributes have all been lost.
Is there any way to keep the session attributes
after the browser is closed?
I test the application with Tomcat3.3,and my
production server doesn't support Session Listener.
We have the Weblogic5.1 server hosting several applications.
We want one of the application only accept HTTPS request on port 7002, and close the HTTP(7001) on this
application.
Is there anyway to configure the application?
Thanks
16 years ago
Made more tests and found it also happened with
http://server:7001
Checked the documents, happen to find that there
was a bug CR 10172, which take the session-timeout from web.xml as "seconds".This is
supposed to be fixed in SP2.
I just changed the session-timeout to be 1800,
seems fine now. But how can it happen,since
we are using the SP8(I was told).

Thanks.
16 years ago
I am not using the response.encodeURL() in
the program, and cookies is turned on.
I test it again, and found if I test the SSL
link https://server:7002/Application
Then, after I hited several buttons, the
session is lost.
If I use the http://server:7001/Application,
it is working.
Thanks
16 years ago
We have a web application which uses Java Servlet, JSP. We developed the application
with Tomcat, and everything is fine.But after
we moved the application to Weblogic 5.1 SP8, we
found sometimes the session is lost.It happends
randomly.Does anyone have this experience?
Any advice is greatly appreciated!
16 years ago
This is a Database transaction thing.You can find
some info from the JDBC tutorial in the SUN JAVA
site.