tomcat jndi

2013-04-29 Thread Jakub 1983
I have read

http://tomcat.apache.org/tomcat-7.0-doc/jndi-datasource-examples-howto.html
http://tomcat.apache.org/tomcat-7.0-doc/jndi-resources-howto.html

1)I would like to ask about essence of jndi
a) jndi as a whole and
b) jndi in tomcat

In all known to me cases jndi in tomcat and in jboss is used only as
http://docs.oracle.com/javase/1.5.0/docs/api/javax/naming/InitialContext.html#lookup%28java.lang.String%29

2) are there any other common uses ?

3) Can we say JNDI in tomcat is a static Map for each application ?
actually a map, that can hold
simple values and objects(int, string),
object factories on which Map.get doesn't return them, but returns objects
created by this factories,
object pools - similar to factories
and this static Map can be configured with xml in web.xml and in
context.xml.

4) Is this a good comparison ?
InitialContext.lookup is not more than Map.get, apart from case of
factories.
5) Or INDI in tomcat has much more functionality ?

6) Is comparison to spring container with scope singleton and prototype
more adequate ?
7) Can we say it is older implementation of spring bean container ?

8)Where is the difference between
a) Map and jndi
b) spring container and jndi

9) can jndi be configured outside of tomcat ? in some other process ?

10) I mostly take part in small projects, where team leader/architect also
deploys app in production, possibly jndi is much more handful in corporate
environment, where war is shipped to admin dedicated tomcat administrator,
who deploys it and configures jdbc connections, and he can't simply change
spring configuration.

11) jndi in contrary to spring is a standard and each tomcat/app server
admin knows it and knows where and how to configure it ?

12) in projects without dedicated tomcat administrator where team leader
makes build and deploys it into production jndi is an excess, and it is
better and more handful to use spring and maven profiles for dev and
production environment ?

12b) in projects as in 12) there is no sense speaking about advantages of
jndi, jndi can be skipped and spring can be used instead.

13) looking into
http://docs.oracle.com/javase/1.5.0/docs/guide/jndi/jndi-dns.html
would be possible in tomcat to map dns as a jndi provider ?
would it work than that InitialContext.lookup(some_appropriate_dns_prefix
+ tomcat.apache.org) would return me ip address ??

14) similar to 13)
http://docs.oracle.com/javase/6/docs/technotes/guides/jndi/jndi-ldap.html
would it be possible in tomcat to map some external ldap as a jndi provider
?
would ctx.lookup(some_appropriate_ldap_prefix +
cn=objects,ou=Sales/some/x/y/z); query ldap ?

15) would 13) and 14) work in tomcat, if not would it work in eg jboss ? if
so what are common some_appropriate_dns_prefix and
some_appropriate_ldap_prefix ?

16) can we add both 13) dns and 14) ldap into tomcat as jndi providers, and
both work in the same webapp with appropriate prefixes, and
java:comp/env/ still returns Resources from web.xml and from context.xml ?

thx for reply in advance, regards
Jakub


Re: getting the request that created the session

2013-04-29 Thread André Warnier

Leo Donahue - RDSA IT wrote:

___
From: Leon Rosenberg [rosenberg.l...@gmail.com]
Subject: Re: getting the request that created the session


 would ServletRequestListener being notified prior to any Filter execution?


According to the docs, yes.

A ServletRequest is defined as coming into scope of a web application when it is 
about to enter the first servlet or filter of the web application, and as going out of 
scope as it exits the last servlet or the first filter in the chain.

http://docs.oracle.com/javaee/6/api/javax/servlet/ServletRequestListener.html 


Leon,
I apologise for insisting, but your initial post said :
Background, I want to count sessions by top level domains...

It was probably politically a bad idea to start by saying that I agreed with 
Martin. ;-)

But if the above is really your final purpose, and the final purpose is more important 
than the way in which you get to it, would it not be simpler and more efficient to do this 
by processing the server's access log, rather than going through all you're going through 
right now ?


Tomcat's AccessLog Valve is indeed specific to Tomcat.
But webserver access logs exist on all webservers, and they tend to have the same general 
format, and contain the same general information (which you can generally also choose 
yourself).  And the programs to read and process them already exist and are widely used.
And they do provide an analysis that shows unique users and/or sessions, based on the 
client's IP (with some filtering already possible and tunable, such as avoiding to count 
your own admin accesses e.g.). And they will resolve the IP's to domains and provide a 
break-down by domain etc.
Have you looked at one such outputs already ? (If not, I can send you a link to an 
example, privately)


I understand that it is less interesting to do it this way than through Request Listeners 
etc., but if the end result is what really matters..


-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Re: tomcat jndi

2013-04-29 Thread Jakub 1983
3) and 4) are answered here
http://stackoverflow.com/questions/1350816/what-is-the-purpose-of-jndi
http://stackoverflow.com/questions/5143499/understanding-jndi
http://www.javaworld.com/javaworld/jw-04-2002/jw-0419-jndi.html
http://technotes.tostaky.biz/2013/01/what-is-jndi-spi-cci-ldap-and-jca.html

other question, especially concerning tomcat are still valid


On Mon, Apr 29, 2013 at 9:21 AM, Jakub 1983 jjaku...@gmail.com wrote:

 I have read

 http://tomcat.apache.org/tomcat-7.0-doc/jndi-datasource-examples-howto.html
 http://tomcat.apache.org/tomcat-7.0-doc/jndi-resources-howto.html

 1)I would like to ask about essence of jndi
 a) jndi as a whole and
 b) jndi in tomcat

 In all known to me cases jndi in tomcat and in jboss is used only as

 http://docs.oracle.com/javase/1.5.0/docs/api/javax/naming/InitialContext.html#lookup%28java.lang.String%29

 2) are there any other common uses ?

 3) Can we say JNDI in tomcat is a static Map for each application ?
 actually a map, that can hold
 simple values and objects(int, string),
 object factories on which Map.get doesn't return them, but returns objects
 created by this factories,
 object pools - similar to factories
 and this static Map can be configured with xml in web.xml and in
 context.xml.

 4) Is this a good comparison ?
 InitialContext.lookup is not more than Map.get, apart from case of
 factories.
 5) Or INDI in tomcat has much more functionality ?

 6) Is comparison to spring container with scope singleton and prototype
 more adequate ?
 7) Can we say it is older implementation of spring bean container ?

 8)Where is the difference between
 a) Map and jndi
 b) spring container and jndi

 9) can jndi be configured outside of tomcat ? in some other process ?

 10) I mostly take part in small projects, where team leader/architect also
 deploys app in production, possibly jndi is much more handful in corporate
 environment, where war is shipped to admin dedicated tomcat administrator,
 who deploys it and configures jdbc connections, and he can't simply change
 spring configuration.

 11) jndi in contrary to spring is a standard and each tomcat/app server
 admin knows it and knows where and how to configure it ?

 12) in projects without dedicated tomcat administrator where team leader
 makes build and deploys it into production jndi is an excess, and it is
 better and more handful to use spring and maven profiles for dev and
 production environment ?

 12b) in projects as in 12) there is no sense speaking about advantages of
 jndi, jndi can be skipped and spring can be used instead.

 13) looking into
 http://docs.oracle.com/javase/1.5.0/docs/guide/jndi/jndi-dns.html
 would be possible in tomcat to map dns as a jndi provider ?
 would it work than that
 InitialContext.lookup(some_appropriate_dns_prefix + tomcat.apache.org)
 would return me ip address ??

 14) similar to 13)
 http://docs.oracle.com/javase/6/docs/technotes/guides/jndi/jndi-ldap.html
 would it be possible in tomcat to map some external ldap as a jndi
 provider ?
 would ctx.lookup(some_appropriate_ldap_prefix +
 cn=objects,ou=Sales/some/x/y/z); query ldap ?

 15) would 13) and 14) work in tomcat, if not would it work in eg jboss ?
 if so what are common some_appropriate_dns_prefix and
 some_appropriate_ldap_prefix ?

 16) can we add both 13) dns and 14) ldap into tomcat as jndi providers,
 and both work in the same webapp with appropriate prefixes, and
 java:comp/env/ still returns Resources from web.xml and from context.xml ?

 thx for reply in advance, regards
 Jakub



Re: getting the request that created the session

2013-04-29 Thread Leon Rosenberg
Hello Andre,


On Mon, Apr 29, 2013 at 10:13 AM, André Warnier a...@ice-sa.com wrote:


 Leon,
 I apologise for insisting, but your initial post said :
 Background, I want to count sessions by top level domains...



Yes, but @Runtime. Means that I want to know how many sessions from each
tld are active _now_.
Parsing http log continuously and instantly would be an overkill in my
opinion. And I don't see a way to see a session expiry in access log ;-)

kind regards
Leon


Re: AsyncListener.onError and disconnected client

2013-04-29 Thread Rossen Stoyanchev

- Original Message -
 From: Mark Thomas ma...@apache.org
 To: Tomcat Users List users@tomcat.apache.org
 Sent: Thursday, April 25, 2013 8:42:55 AM
 Subject: Re: AsyncListener.onError and disconnected client


 It is. The issue is when is happens.
 
 The issue is that there is no event (I am aware of) that the
 container
 can monitor.
 
 BIO - Only know once a read/write fails.
 
 NIO - A current read/write will fail.
   The socket can be explicitly tested (but isn't currently)
   If the socket is in the poller I'd expect an error event
   If the socket was added to the poller I'd expect an error event
 
 APR - A current read/write will fail.
   If the socket is in the poller I'd expect an error event
   If the socket was added to the poller I'd expect an error event
   It might be possible to test the socket but I haven't checked
 
 There are times when a socket is not being used for read/write and is
 not in a poller (e.g. when the app is doing some processing that
 doesn't require output to the user agent). You won't get a notification of
 disconnect in this case until the app has finished.
 
 I wonder (for NIO and APR) if you could always have the socket in the
 poller in order to detect a disconnect? 

Would it be feasible to test sockets periodically? I can imagine some such 
logic is used to track async request timeouts. Possibly not all sockets, but 
only the ones in async mode, which should be a smaller subset. Since the 
recommended time for long poll duration is around 30 seconds, checking every 5 
seconds would go a long way.

Of course if keeping the socket in the poller is possible, instant detection 
(as with WebSockets) would be ideal.

 This really comes down to how the spec has been written. onError is
 for errors that happen in the container during dispatch (i.e. at the end
 of the async phase) that the app does not have visibility of. It allows
 the container to tell the app that the request did not complete normally.
 It is not intended for IO errors that happen during the async phase
 which the app can just catch.

Thanks for all the explanations!

Rossen

-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



validationQuery with Tomcat 7 JDBC Pool

2013-04-29 Thread Jose María Zaragoza
Hello:

I was using validationQuery in Tomcat 6 for JNDI datasources, so to check
connections before borrowing to the caller
And, about documentacion, testOnBorrow parameter is true by default

testOnBorrow - true or false: whether a connection should be validated
using the validation query each time it is borrowed from the pool. Default:
true

http://tomcat.apache.org/tomcat-6.0-doc/jndi-resources-howto.html

And all works fine


Now , I want to use JDBC Pool with a new web application deployed on that
Tomcat 6.
So, I consider it as an standalone application, and I use
org.apache.tomcat.jdbc.pool.DataSource class ( I use Spring-MyBatis to
configure datasource , injecting it as a  bean)

I've read in Tomcat 7 JDBC pool documentation that testOnBorrow is false by
default in this case
Is it right ? Must I define testOnBorrow = true explicitly ?
It's little bit strange that default values be different either access by
JNDI or bean  instantiation

Should I use org.apache.tomcat.jdbc.pool.DataSourceFactory instead
of org.apache.tomcat.jdbc.pool.DataSource ?
My doubt is if one is better than other in performance terms

Should I use META-INF/context.xml and to use Resource ?

Thanks and regards


Re: getting the request that created the session

2013-04-29 Thread Christopher Schultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA256

Leon,

On 4/29/13 9:05 AM, Leon Rosenberg wrote:
 Hello Andre,
 
 
 On Mon, Apr 29, 2013 at 10:13 AM, André Warnier a...@ice-sa.com
 wrote:
 
 
 Leon, I apologise for insisting, but your initial post said : 
 Background, I want to count sessions by top level domains...
 
 
 
 Yes, but @Runtime. Means that I want to know how many sessions from
 each tld are active _now_. Parsing http log continuously and
 instantly would be an overkill in my opinion. And I don't see a way
 to see a session expiry in access log ;-)

So your initial implementation was a Filter that marked each
HttpSession with the origin IP address (so you could get the TLD of
the user) and then a Listener to keep track of the sessions? What's
wrong with that?

 Output for
 http://localhost:8080/moskitodemo/mui/mskShowAllProducers: Request
 1 created /moskitodemo/mui/mskShowAllProducers Session created
 4B842C774B30EE7886CC7243758C7D38 Request 2 created
 /moskitodemo/mui/mskCSS Session? true Session
 4B842C774B30EE7886CC7243758C7D38 new? true Request 3 created
 /moskitodemo/img/moskito_webui_logo.gif Session? true Session
 4B842C774B30EE7886CC7243758C7D38 new? true Request 4 created
 /moskitodemo/js/wz_tooltip.js Session? true Session
 4B842C774B30EE7886CC7243758C7D38 new? true Request 5 created
 /moskitodemo/js/jquery-1.4.min.js Session? true Session
 4B842C774B30EE7886CC7243758C7D38 new? true Request 6 created
 /moskitodemo/js/function.js Session? true Session
 4B842C774B30EE7886CC7243758C7D38 new? true Request 6 destroyed
 /moskitodemo/js/function.js Request 5 destroyed
 /moskitodemo/js/jquery-1.4.min.js Request 4 destroyed
 /moskitodemo/js/wz_tooltip.js Request 3 destroyed
 /moskitodemo/img/moskito_webui_logo.gif

That does appear a little odd to me. Can you show an HTTP protocol
trace of that interaction? I'd be interested to see what request was
what and exactly what it held (and whether they were keepalives, etc.).

- -chris
-BEGIN PGP SIGNATURE-
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQIcBAEBCAAGBQJRfnpjAAoJEBzwKT+lPKRYp1AP/15ijJOAxMkT8ZvVLm3r8jb8
w30OVaIOerFINsE3DL74mngd8pcNR/d2SQoYkMLM3oT42Z/p/Qufy9sLfuti9vkR
RAYq9Q0PUmUGTGilWL3eraEqPfXUo1ZVQrC3W9MyvzGraq1sIaJqqWb8fm/N3z9d
n0LHenBcjmt8OfySFWSQ8uTfSjdE+KhO0Nqca0sMIUQsGjbrklVwgkyJ8F+auLaY
CwS4gSR7I6i785ITNu2XHnGeQLQRonYPTQHiXueEniBKbvCQp4In4antwpPVihrO
2oTUHP2eORe+WvRrUzHDkuZRFhXIHKI5NWuN7HtLsy0xLDgZVJRBys78GI0ulCrG
M1KYEpkQFXgHFCZdV3foRkW9XNcCBKdX4ExjZcjoE1pLL2yk5sAePrWeYNS9Bfv0
JKLwdI8J+ofnmJc2ZJazYmA+Ig7PAG74sa02j3izEuRV8B4saUc7mJvUkXusc/qC
+qxwQY779ucf77LCY5OIvN/KZU1NOsrDrIrUYyFgjK5m8r7PIvRg8l77z1Bh74na
n70/3dTNWmYC1w5WW1WLEUyXJXcrPeQsijWbfnoY8sBvVvLbxOvb/w5dU7WiwxdD
3wxOYNc4TQoaAVsoMS9xs1V1+llxVZXDW/cJeBlgotCNoZNYk8MAZhsuHw1PkyqF
FgADHu45Qxy/bKZbEN7S
=HgoD
-END PGP SIGNATURE-

-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Re: getting the request that created the session

2013-04-29 Thread André Warnier

Leon Rosenberg wrote:

Hello Andre,


On Mon, Apr 29, 2013 at 10:13 AM, André Warnier a...@ice-sa.com wrote:


Leon,
I apologise for insisting, but your initial post said :
Background, I want to count sessions by top level domains...




Yes, but @Runtime. Means that I want to know how many sessions from each
tld are active _now_.


Ok then, right.  But you didn't really specify that in your initial 
requirements.


Parsing http log continuously and instantly would be an overkill in my
opinion. 


Agreed.

And I don't see a way to see a session expiry in access log ;-)




Ok, I give up. I was just making sure that you did get the correct meaning of my initial 
suggestion.



..although, when I think about it again :

- under Unix/Linux, there is a command tail -f filename, which continuously watches 
for any lines added to a file and displays them.  It doesn't seem to be very intensive in 
terms of resources used.

- and on the other hand, you probably have a session expiration timeout.
So you could in theory say that you note the start of a session, and then update this each 
time there is a new access to that same session.  And then periodically, you go through 
your table and for each session which you haven't seen since some time = the session 
timeout, you consider it expired.


At which time of course I don't know if this is any simpler than the solution which you 
are exploring right now.

;-)

-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Java Applet can not communicate with Java Servlet

2013-04-29 Thread qingtao peng
  I have built the apache-tomcat-7.0.32 server on my computer.My operating 
system is Windows7.I have written  an Applet and compiled it .The  source code 
of the Applet is as follow :

import java.awt.*;
import java.applet.*;
import java.awt.event.*;
import java.io.*;
import java.net.*;
public class DbApplet extends Applet implements ActionListener
{
TextField tfQuery;
TextArea taResults;
Button btnExecute;
URL chatURL;
public void init()
{
Panel pa = new Panel();
pa.setLayout(new FlowLayout(FlowLayout.LEFT));
pa.add(new Label(查询串:));
tfQuery = new TextField(SELECT number,code,score from chengji WHERE 
code='3001',50);
pa.add(tfQuery);
btnExecute = new Button(查询);
btnExecute.addActionListener(this);
pa.add(btnExecute);
add(North,pa);
taResults = new TextArea(30,60);
add(Center,taResults);
chatURL = getCodeBase();
}
public void actionPerformed(ActionEvent evt)
{
String lbl = evt.getActionCommand();
if(lbl.equals(查询))
{
String qryString = tfQuery.getText();
try
{
String qry = URLEncoder.encode(qry,UTF-8) + = +
URLEncoder.encode(qryString,UTF-8);
String str = http://localhost:8080/Servlet/DbServlet;;
URL urlName = new URL(str);
URLConnection uc = urlName.openConnection();
uc.setDoOutput(true);
uc.setDoInput(true);
uc.setUseCaches(false);
uc.setRequestProperty(Content-type,application/xwww-form-urlencoded);
DataOutputStream dos = new
DataOutputStream(uc.getOutputStream());
dos.writeBytes(qry);
dos.close();
InputStreamReader in = new
InputStreamReader(uc.getInputStream());
int chr = in.read();
while(chr != -1)
{
taResults.append(String.valueOf((char)chr));
chr = in.read();
}
in.close();
}
catch(MalformedURLException e)
{
taResults.setText(e.toString());
}
catch(IOException e)
{
taResults.setText(e.toString());
}
}
}
}
This compiled Applet has been embedded in a HTML file named with DbApplet.htm.
The  source code of the Servlet is as follow : 


import java.io.IOException;
import java.io.PrintWriter;
import java.net.URLDecoder;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Servlet implementation class DbServlet
 */
public class DbServlet extends HttpServlet {
/**
 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse 
response)
 */
protected void doPost(HttpServletRequest req, HttpServletResponse res) throws 
ServletException, IOException {
PrintWriter out = res.getWriter();
res.setContentType(text/html;charset=GB2312);
String qry = req.getParameter(qry);
qry = URLDecoder.decode(qry,UTF-8);
out.println(qry);
Connection dbCon = null;
try
{
Class.forName(sun.jdbc.odbc.JdbcOdbcDriver);
String dbURL = jdbc:odbc:STU;
dbCon = DriverManager.getConnection(dbURL,,);
PreparedStatement p = dbCon.prepareStatement(qry);
ResultSet rs = p.executeQuery();
while(rs.next())
{
out.print(rs.getString(1));
out.print(rs.getString(2) +  );
out.println(rs.getInt(3));
}
}
catch(Exception e)
{
out.println(读写数据库出错: + e.getMessage());
}
finally
{
try
{
dbCon.close();
out.close();
}
catch(Exception e)
{
out.println(关闭数据库出错: + e.getMessage());
}
}
// TODO Auto-generated method stub
}

}

I have started the apache-tomcat-7.0.32 server ,then I have typed the network 
address of DbApplet.htm in the  address field of the browser.I click on the 
button in the Applet,but  receive java.io.FileNotFoundException error.The error 
is java.io.FileNotFoundException: http://localhost:8080/Servlet/DbServlet.Where 
do I place DbServlet ? That is, which directory  do I place under in 
apache-tomcat-7.0.32. What is the network address of this Servlet .I thank for 
helps.

Re: Java Applet can not communicate with Java Servlet

2013-04-29 Thread André Warnier

qingtao peng wrote:

  I have built the apache-tomcat-7.0.32 server on my computer.My operating 
system is Windows7.I have written  an Applet and compiled it .The  source code 
of the Applet is as follow :


...


This compiled Applet has been embedded in a HTML file named with DbApplet.htm.
The  source code of the Servlet is as follow : 


...



I have started the apache-tomcat-7.0.32 server ,then I have typed the network 
address of DbApplet.htm in the  address field of the browser.I click on the 
button in the Applet,but  receive java.io.FileNotFoundException error.The error 
is java.io.FileNotFoundException: http://localhost:8080/Servlet/DbServlet.Where 
do I place DbServlet ? That is, which directory  do I place under in 
apache-tomcat-7.0.32. What is the network address of this Servlet .I thank for 
helps.


Hi.

Simplify the problem.

1) In your HTML page, there is the tag that retrieves the applet from the server. What is 
the URL from which the applet is being retrieved ?


2) if it is like /Servlet/DbServlet, then the .jar file in which your compiled applet is 
embedded, should be in the directory (tomcat-install-dir)/webapps/Servlet/.


3) if it is indeed a .jar file, then it should be the file 
(tomcat-install-dir)/webapps/Servlet/DbServlet.jar
and you should be able to retrieve it if you enter the following URL in your browser's URL 
bar : http://localhost:8080/Servlet/DbServlet.jar;

(The browser will probably ask you where to save that file, it will not run it 
in this case).

Note: when the browser has retrieved your HTML page from the server, it sees the applet 
tag in the HTML page. It then makes another request to the server, to retrieve the applet 
from the server in exactly the same way as if this was for example an image from an img tag.
It is only after it has retrieved the applet, that the browser will activate its Java 
run-time machine, to actually run the applet.



-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Re: getting the request that created the session

2013-04-29 Thread Leon Rosenberg
On Mon, Apr 29, 2013 at 3:49 PM, Christopher Schultz 
ch...@christopherschultz.net wrote:

 -BEGIN PGP SIGNED MESSAGE-
 Hash: SHA256

 Leon,


 So your initial implementation was a Filter that marked each
 HttpSession with the origin IP address (so you could get the TLD of
 the user) and then a Listener to keep track of the sessions? What's
 wrong with that?


It seemed to complicated.
I now could strip it down to 1 file, that is both HttpSession and
ServletRequest- Listener:
http://svn.anotheria.net/opensource/moskito/trunk/moskito-web/java/net/anotheria/moskito/web/session/SessionByTldListener.java

The drawback is, I can count only from second request, because the session
is created later. And I don't want to create sessions on all requests.
I'm thinking about moving (duplicating) the call in requestDestroyed.



  Output for
  http://localhost:8080/moskitodemo/mui/mskShowAllProducers: Request
  1 created /moskitodemo/mui/mskShowAllProducers Session created
  4B842C774B30EE7886CC7243758C7D38 Request 2 created
  /moskitodemo/mui/mskCSS Session? true Session
  4B842C774B30EE7886CC7243758C7D38 new? true Request 3 created
  /moskitodemo/img/moskito_webui_logo.gif Session? true Session
  4B842C774B30EE7886CC7243758C7D38 new? true Request 4 created
  /moskitodemo/js/wz_tooltip.js Session? true Session
  4B842C774B30EE7886CC7243758C7D38 new? true Request 5 created
  /moskitodemo/js/jquery-1.4.min.js Session? true Session
  4B842C774B30EE7886CC7243758C7D38 new? true Request 6 created
  /moskitodemo/js/function.js Session? true Session
  4B842C774B30EE7886CC7243758C7D38 new? true Request 6 destroyed
  /moskitodemo/js/function.js Request 5 destroyed
  /moskitodemo/js/jquery-1.4.min.js Request 4 destroyed
  /moskitodemo/js/wz_tooltip.js Request 3 destroyed
  /moskitodemo/img/moskito_webui_logo.gif

 That does appear a little odd to me. Can you show an HTTP protocol
 trace of that interaction? I'd be interested to see what request was
 what and exactly what it held (and whether they were keepalives, etc.).


The request that occur simultaneously in chrome(only) are pictures and js,
replied with 304:

   1. Request URL:
   http://localhost:8080/moskitodemo/js/wz_tooltip.js
   2. Request Method:
   GET
   3. Status Code:
   304 Not Modified
   4. Request Headersview source
  1. Accept:
  */*
  2. Accept-Encoding:
  gzip,deflate,sdch
  3. Accept-Language:
  en-US,en;q=0.8
  4. Cache-Control:
  max-age=0
  5. Connection:
  keep-alive
  6. Cookie:
  JSESSIONID=71474A695869D2494E2135CBCEAF
  7. Host:
  localhost:8080
  8. If-Modified-Since:
  Sat, 27 Apr 2013 21:49:44 GMT
  9. If-None-Match:
  W/35082-1367099384000
  10. Referer:
  http://localhost:8080/moskitodemo/mui/mskShowAllProducers
  11. User-Agent:
  Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_3) AppleWebKit/537.36
  (KHTML, like Gecko) Chrome/27.0.1453.65 Safari/537.36
  5. Response Headersview source
  1. Date:
  Mon, 29 Apr 2013 14:24:36 GMT
  2. ETag:
  W/35082-1367099384000
  3. Server:
  Apache-Coyote/1.1


Even, the requests are keepalived they look to me as if they were executed
parallel. At least from the chrome timeline. But its hard to tell without
further investigation.

You can check yourself:
http://server04.test.anotheria.net:8080/moskitodemo/mui/mskShowAllProducers


The TestListener code:
http://svn.anotheria.net/opensource/moskito/trunk/moskito-web/java/net/anotheria/moskito/web/session/TestListener.java



regards
Leon


 - -chris
 -BEGIN PGP SIGNATURE-
 Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
 Comment: GPGTools - http://gpgtools.org
 Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

 iQIcBAEBCAAGBQJRfnpjAAoJEBzwKT+lPKRYp1AP/15ijJOAxMkT8ZvVLm3r8jb8
 w30OVaIOerFINsE3DL74mngd8pcNR/d2SQoYkMLM3oT42Z/p/Qufy9sLfuti9vkR
 RAYq9Q0PUmUGTGilWL3eraEqPfXUo1ZVQrC3W9MyvzGraq1sIaJqqWb8fm/N3z9d
 n0LHenBcjmt8OfySFWSQ8uTfSjdE+KhO0Nqca0sMIUQsGjbrklVwgkyJ8F+auLaY
 CwS4gSR7I6i785ITNu2XHnGeQLQRonYPTQHiXueEniBKbvCQp4In4antwpPVihrO
 2oTUHP2eORe+WvRrUzHDkuZRFhXIHKI5NWuN7HtLsy0xLDgZVJRBys78GI0ulCrG
 M1KYEpkQFXgHFCZdV3foRkW9XNcCBKdX4ExjZcjoE1pLL2yk5sAePrWeYNS9Bfv0
 JKLwdI8J+ofnmJc2ZJazYmA+Ig7PAG74sa02j3izEuRV8B4saUc7mJvUkXusc/qC
 +qxwQY779ucf77LCY5OIvN/KZU1NOsrDrIrUYyFgjK5m8r7PIvRg8l77z1Bh74na
 n70/3dTNWmYC1w5WW1WLEUyXJXcrPeQsijWbfnoY8sBvVvLbxOvb/w5dU7WiwxdD
 3wxOYNc4TQoaAVsoMS9xs1V1+llxVZXDW/cJeBlgotCNoZNYk8MAZhsuHw1PkyqF
 FgADHu45Qxy/bKZbEN7S
 =HgoD
 -END PGP SIGNATURE-

 -
 To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
 For additional commands, e-mail: users-h...@tomcat.apache.org




Re: Java Applet can not communicate with Java Servlet

2013-04-29 Thread André Warnier

André Warnier wrote:

qingtao peng wrote:
  I have built the apache-tomcat-7.0.32 server on my computer.My 
operating system is Windows7.I have written  an Applet and compiled it 
.The  source code of the Applet is as follow :



...

This compiled Applet has been embedded in a HTML file named with 
DbApplet.htm.

The  source code of the Servlet is as follow :

...



I have started the apache-tomcat-7.0.32 server ,then I have typed the 
network address of DbApplet.htm in the  address field of the browser.I 
click on the button in the Applet,but  receive 
java.io.FileNotFoundException error.The error is 
java.io.FileNotFoundException: 
http://localhost:8080/Servlet/DbServlet.Where do I place DbServlet ? 
That is, which directory  do I place under in apache-tomcat-7.0.32. 
What is the network address of this Servlet .I thank for helps.


Hi.

Simplify the problem.

1) In your HTML page, there is the tag that retrieves the applet from 
the server. What is the URL from which the applet is being retrieved ?


2) if it is like /Servlet/DbServlet, then the .jar file in which your 
compiled applet is embedded, should be in the directory 
(tomcat-install-dir)/webapps/Servlet/.


3) if it is indeed a .jar file, then it should be the file 
(tomcat-install-dir)/webapps/Servlet/DbServlet.jar
and you should be able to retrieve it if you enter the following URL in 
your browser's URL bar : http://localhost:8080/Servlet/DbServlet.jar;
(The browser will probably ask you where to save that file, it will not 
run it in this case).


Note: when the browser has retrieved your HTML page from the server, it 
sees the applet tag in the HTML page. It then makes another request to 
the server, to retrieve the applet from the server in exactly the same 
way as if this was for example an image from an img tag.
It is only after it has retrieved the applet, that the browser will 
activate its Java run-time machine, to actually run the applet.



---
Sorry, it looks like I misunderstood the issue above.
From what you write, it seems that the applet is being loaded by the browser - since you 
can click on it's button.
So you are getting a java.io.FileNotFoundException error.  Where do you get that error 
message ? in the browser page returned by the server when you click on the applet button ?

If so, then it is your servlet (on the server side) that is getting that error.
And then /you/ have to find out why it is getting that error.
There would be nothing wrong with Tomcat. It is your application which makes 
the error happen.


-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Re: getting the request that created the session

2013-04-29 Thread Howard W. Smith, Jr.
On Mon, Apr 29, 2013 at 9:54 AM, André Warnier a...@ice-sa.com wrote:


 - under Unix/Linux, there is a command tail -f filename, which
 continuously watches for any lines added to a file and displays them.  It
 doesn't seem to be very intensive in terms of resources used.
 - and on the other hand, you probably have a session expiration timeout.
 So you could in theory say that you note the start of a session, and then
 update this each time there is a new access to that same session.  And then
 periodically, you go through your table and for each session which you
 haven't seen since some time = the session timeout, you consider it
 expired.

 At which time of course I don't know if this is any simpler than the
 solution which you are exploring right now.
 ;-)


With all respect, I have to say that looks like a lot of I/O right there
and a huge hit in performance and I would assume this would hit memory in a
bad way as well, but please correct/enlighten me.

Also, I'm following this thread, because I have filter in place for similar
reason, keeping track of new sessions created, expiring, etc..., and filter
meets my need 100% and don't see why one would want to 'avoid' using a
filter.

Yes, I was looking at the performance of 'filter' and all that i'm doing in
'filter' on 'every request', but in retrospect, I don't see my filter
implementation being much of an hinderance in performance. I have to take
another look though and confirm what I'm saying here.


Re: validationQuery with Tomcat 7 JDBC Pool

2013-04-29 Thread Christopher Schultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA256

Jose,

On 4/29/13 9:30 AM, Jose María Zaragoza wrote:
 Now , I want to use JDBC Pool with a new web application deployed
 on that Tomcat 6. So, I consider it as an standalone application,
 and I use org.apache.tomcat.jdbc.pool.DataSource class ( I use
 Spring-MyBatis to configure datasource , injecting it as a  bean)

If you are using Spring-MyBatis to configure the DataSource, then
Tomcat has nothing to do with it (other than you are using Tomcat's
jdbc-pool as a library).

 I've read in Tomcat 7 JDBC pool documentation that testOnBorrow is
 false by default in this case Is it right ?

The default for testOnBorrow is false in all cases, including this one.

 Must I define testOnBorrow = true explicitly ?

If you want to enable testOnBorrow, then yes, you must define it
explicitly.

 It's little bit strange that default values be different either
 access by JNDI or bean  instantiation

I don't see any inconsistency. The default values are different for
Tomcat's jdbc-pool and commons-dbcp, but they are different libraries
so different defaults isn't be unexpected. Given that Tomcat's
jdbc-pool should be a drop-in replacement for commons-dbcp, I would
have expected the defaults to be the same, but in this case the
authors chose not to do this (probably to reduce the in-memory
footprint of jdbc-pool under its default configuration, because I
believe testOnBorrow is implemented as an interceptor so every object
check-out goes through another method call). Also, testOnBorrow is a
fairly wasteful configuration given that most pools have a lot of
activity. Checking a connection on a schedule is much more efficient
than testing every single check-out.

 Should I use org.apache.tomcat.jdbc.pool.DataSourceFactory instead 
 of org.apache.tomcat.jdbc.pool.DataSource ?

Why? An object of the DataSourceFactory class produces objects of the
DataSource class. I don't believe they are interchangeable.

 My doubt is if one is better than other in performance terms
 
 Should I use META-INF/context.xml and to use Resource ?

If you want to use Resource, then don't use Spring-MyBatis to
configure the DataSource... only to inject it into your data service
objects. You'll still have to configure it /properly/, though.

- -chris
-BEGIN PGP SIGNATURE-
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQIcBAEBCAAGBQJRfofiAAoJEBzwKT+lPKRYaNwQAKUNqTTgp0ivZhz2j4af2MHD
xlTr8cNAUl0jSLHJFQuagMVFHLt9pPsLvaWxfx+NCOS/jgPb5dQcmoWPXW/hw1MR
xvIL45CmF8DUoo3Cl1f36ajCqpkxm40aYWJ7D1czc2vysr+9OAno8ZGPt9vG4Llb
lNps2nyGmt1CtXWLQwL2kiBuYruZ6GEE47aVNESBQ4q3FiPNoX1emVBbBCNBSGi0
mlsCh4gNnfcTtvbj+3RQBPXSfXUVE/uf8t1c7c4w1UDkrt3LcLRKjtQchSRSy/tU
bHc70nw8XsQPax9SalxIY2vmfy0/adQAuH+gTqdCt9e4G2HihGGYl3Od83Goh0Z3
Rm5VK+e4WWqKxUpreVBgz14farB2zCOnKbDlEm7TGLUrm4ebMEMBhbHAqYGsG5/P
bfsce9La8U15fY6HAepqAtAGVt1xwUwOgQ0E1y3G2LJ5l9vLw5jsltpzC7sF760c
M+a7HMYU9PEfw/xcmWgkRtap6skE7RGwnteI864en7lM3DYusxAVHFwptu9FYW3t
eucWd7BT6l7EfmEVf5/K+tBKJld9irUP/iOcL9Cndf8uz05oFo8QyxLtHlVzkw5k
v4MCjZQi9hP8vkGfAAW/N9pN/mommEVMtLvGB2M011kRsp+1kRitjqJWChKpuD2v
S8g0n6RQuGyvvBaI6EaT
=axfr
-END PGP SIGNATURE-

-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Re: getting the request that created the session

2013-04-29 Thread Christopher Schultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA256

Leon,

On 4/29/13 10:36 AM, Leon Rosenberg wrote:
 On Mon, Apr 29, 2013 at 3:49 PM, Christopher Schultz  
 ch...@christopherschultz.net wrote:
 
 Leon,
 
 
 So your initial implementation was a Filter that marked each 
 HttpSession with the origin IP address (so you could get the TLD
 of the user) and then a Listener to keep track of the sessions?
 What's wrong with that?
 
 
 It seemed to complicated. I now could strip it down to 1 file,
 that is both HttpSession and ServletRequest- Listener: 
 http://svn.anotheria.net/opensource/moskito/trunk/moskito-web/java/net/anotheria/moskito/web/session/SessionByTldListener.java

Note
 
that, although this is a single class, you might get two separate
objects created by Tomcat: one as the ServletContextListener and one
as the HttpSessionListener. How do you attach the listeners to the
webapp? Via web.xml or some other way?

I don't know what the container does if a listener implements more
than one interface... I've never personally cared about such a scenario.

 The drawback is, I can count only from second request, because
 the session is created later. And I don't want to create sessions
 on all requests. I'm thinking about moving (duplicating) the call
 in requestDestroyed.

Well, you only care about requests that actually create sessions, so
the first request is not really relevant. Or do you mean that the
request listener gets the event /before/ the session is created. Hmm.

 The request that occur simultaneously in chrome(only) are
 pictures and js, replied with 304:
 
 1. Request URL: 
 http://localhost:8080/moskitodemo/js/wz_tooltip.js 2. Request
 Method: GET 3. Status Code: 304 Not Modified 4. Request
 Headersview source 1. Accept: */* 2. Accept-Encoding: 
 gzip,deflate,sdch 3. Accept-Language: en-US,en;q=0.8 4.
 Cache-Control: max-age=0 5. Connection: keep-alive 6. Cookie: 
 JSESSIONID=71474A695869D2494E2135CBCEAF 7. Host: 
 localhost:8080 8. If-Modified-Since: Sat, 27 Apr 2013 21:49:44
 GMT 9. If-None-Match: W/35082-1367099384000 10. Referer: 
 http://localhost:8080/moskitodemo/mui/mskShowAllProducers 11.
 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_3)
 AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.65
 Safari/537.36 5. Response Headersview source 1. Date: Mon, 29 Apr
 2013 14:24:36 GMT 2. ETag: W/35082-1367099384000 3. Server: 
 Apache-Coyote/1.1
 
 
 Even, the requests are keepalived they look to me as if they were
 executed parallel. At least from the chrome timeline. But its
 hard to tell without further investigation.

Yeah, you might have to use a packet-sniffer.

- -chris
-BEGIN PGP SIGNATURE-
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQIcBAEBCAAGBQJRfomfAAoJEBzwKT+lPKRY89cQAJjLc/xH++tfrNubd9eE+3s3
UKI5prfRYogHXsXzUG/sB1GS2Gpii+6Qtzuen+/9eHp9zfirKWpWFhk2yPQi1MTz
oyXQmrXOlYtKwg9iX7FQnkrHfzXbT3Qx5vzrHemf4uwOBhZ9SyutzJsomeHi8Ev0
B7VMZoKz+APyDLQvCyEYKrJpFwtTcD18RaknUKQzgYxFafh98jL6J0icyv3gq9JW
MJdl1VSgY0SdkoYitAmDE4Z0qQ9pV6QbS7z4W0VBC9UzxwsG6c+c94ncz3G4WKaa
mTNvY7SO/PR/z7FNbfo9AO6pvCZ+5SGnxoQ6C99BdJ/Eo8F78tSVR36H7IC5gNKz
rDJN5tLkCIRcWz3KHeqstL4EnB7FyO838bSamKdOExAEa5+zZCREf8T9D4L6dcCb
s+bxB+j/fJKSIRXkfiqNozIJ+uwPmr1P/vEqiWEjEVdMJEo2ByTK4Jnx8FJcAi99
sgVLK0fTH+7J85sSArF2zatZO8LxPE860rNR2CbU/NeeXI1MhxlJnGgPd6jIuOtA
8QA17rilYIOWp4icQOqubS2j4g3HmpgMDGnoD59DDJRN5odUPQEDzYYD04XjjeQp
VZFSUdThfxSIzp4CBLmHXTiHXMkgflu5MF0aq0oa6T0eU6SNXkoAr7TC4wB/sHNR
2JCE36iSziLeIJHKTgmQ
=W8Ia
-END PGP SIGNATURE-

-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Re: getting the request that created the session

2013-04-29 Thread Howard W. Smith, Jr.
On Mon, Apr 29, 2013 at 10:54 AM, Christopher Schultz 
ch...@christopherschultz.net wrote:

 -BEGIN PGP SIGNED MESSAGE-
 Hash: SHA256
  
  Even, the requests are keepalived they look to me as if they were
  executed parallel. At least from the chrome timeline. But its
  hard to tell without further investigation.

 Yeah, you might have to use a packet-sniffer.


definitely sounds like overkill. how much code you need to write for such a
thing, all because one would want to avoid using a filter???


Re: Java Applet can not communicate with Java Servlet

2013-04-29 Thread Christopher Schultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA256

Peng,

On 4/29/13 10:05 AM, qingtao peng wrote:
 uc.setRequestProperty(Content-type,application/xwww-form-urlencoded);

I
 
think you want:

application/x-www-form-urlencoded

 res.setContentType(text/html;charset=GB2312);

Why not use UTF-8 like you did in the Applet? What you have done is
not wrong and it should work, but it does seem a little odd to use
different character encodings in different places.

 I have started the apache-tomcat-7.0.32 server ,then I have typed
 the network address of DbApplet.htm in the  address field of the 
 browser.I click on the button in the Applet,but  receive 
 java.io.FileNotFoundException error.The error is 
 java.io.FileNotFoundException: 
 http://localhost:8080/Servlet/DbServlet.Where do I place DbServlet
 ?

The servlet spec says that all servlets need to be in a package. So
you should have a package statement at the top of your .java file,
then re-compile.

 That is, which directory  do I place under in
 apache-tomcat-7.0.32.

Assuming your package is my.pkg, then you want your .class file here:

.../mywebapp/WEB-INF/classes/my/pkg/DbServlet.class

 What is the network address of this Servlet .I thank for helps.

Network address (hostname) will be wherever you configured Tomcat to
listen (localhost? www.foo.com?). The URL will depend upon how you
have mapped the servlet in web.xml. Have you done that?

- -chris
-BEGIN PGP SIGNATURE-
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQIcBAEBCAAGBQJRfotFAAoJEBzwKT+lPKRYOLMP/0XuXo5m06m6cXUfv90Ngh+U
Vpy4L9y8WCWpHthtJqxk4EDRLT1K0Y5hV6cW0S7BzeH9ynh2VaKVvcWMR3KPcwts
Pc60/TUMj7qGLzXkTfBxxUnWGzY6fQLq4KRJdiHDQvycnw/KwYbM1FjDU9PjG2vi
yeEZQhEqMrP+fHCq8bYLAH+nuqngIGt59HGlN+1Umz5rsguSu6uq/ymaXUYEzyXZ
k1lqDwKSTGn7x4LD+AOqzJxH549bMjFVqexE5Fw4yFCfxChAP7zQwnDhL1jkKcsB
TXZJKQ5wNqQmHYg/C/9Cf+jKg7wmF6nEyw3FB4zDcYhKnGXaBBq2S8zF61Y8wKq3
QPkbyMfC8zPivXC1Jx28TyDJVQ81SLyKGB9JYfLZSuGvpN3rEV5sXOVrwKZw4+D7
mRYrwCYshm2/ueFALPXEjZbbAQHiXSqISDSdiMxYbIazMOCgxwcWcBfh7Rd2/g5+
rWU/xDdM0rUaIEkRVfA5bVQg9zNOqqoZFe7aEFNlBK0Y02LY2G9Bi2VtrfVMVnHo
gXxf0efIn7fyI9ajsh1JFm/f+NxKvZissEPqDRr7pWV0qyqcr8YfErrPT6jYMPl9
lGSF2RIFXO2zaxJ2x6pwnLxWl/EYXxayFPqoCQXTw3lBRLaCeVG+Ftw+l8ni+Gm7
aIzoBlfT46MVINdwePvB
=UAT7
-END PGP SIGNATURE-

-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Re: getting the request that created the session

2013-04-29 Thread Leon Rosenberg
Hello Howard,
the sniffer thing has nothing to do with original topic, I was just
wandering that some requests were having session marked as new, which
actually shouldn't be the case. Or in other word, the naive understanding
of session.isNew method is that it should only return true once. But it did
to it multiple times. The was strange, and christopher and myself were
talking about investigating it further.

Back to your question, filter is ok, too many filters are making stack
traces fuller than needed, and the order of the filter could be a problem.
Listener is asked _before_ anything happens.

regards
Leon


On Mon, Apr 29, 2013 at 4:59 PM, Howard W. Smith, Jr. 
smithh032...@gmail.com wrote:

 On Mon, Apr 29, 2013 at 10:54 AM, Christopher Schultz 
 ch...@christopherschultz.net wrote:

  -BEGIN PGP SIGNED MESSAGE-
  Hash: SHA256
   
   Even, the requests are keepalived they look to me as if they were
   executed parallel. At least from the chrome timeline. But its
   hard to tell without further investigation.
 
  Yeah, you might have to use a packet-sniffer.
 
 
 definitely sounds like overkill. how much code you need to write for such a
 thing, all because one would want to avoid using a filter???



Re: getting the request that created the session

2013-04-29 Thread Leon Rosenberg
On Mon, Apr 29, 2013 at 4:54 PM, Christopher Schultz 
ch...@christopherschultz.net wrote:

 -BEGIN PGP SIGNED MESSAGE-
 Hash: SHA256

 Leon,

 On 4/29/13 10:36 AM, Leon Rosenberg wrote:
  On Mon, Apr 29, 2013 at 3:49 PM, Christopher Schultz 
  ch...@christopherschultz.net wrote:
 
  Leon,
 
 
  So your initial implementation was a Filter that marked each
  HttpSession with the origin IP address (so you could get the TLD
  of the user) and then a Listener to keep track of the sessions?
  What's wrong with that?
 
 
  It seemed to complicated. I now could strip it down to 1 file,
  that is both HttpSession and ServletRequest- Listener:
 
 http://svn.anotheria.net/opensource/moskito/trunk/moskito-web/java/net/anotheria/moskito/web/session/SessionByTldListener.java

 Note
 
 that, although this is a single class, you might get two separate
 objects created by Tomcat: one as the ServletContextListener and one
 as the HttpSessionListener. How do you attach the listeners to the
 webapp? Via web.xml or some other way?


one entry in the web.xml for now. It works at least in tomcat 7, but I
haven't tested it further. Its also the same object (now). But you are
right, I will make the counting part static ;-).



 I don't know what the container does if a listener implements more
 than one interface... I've never personally cared about such a scenario.

  The drawback is, I can count only from second request, because
  the session is created later. And I don't want to create sessions
  on all requests. I'm thinking about moving (duplicating) the call
  in requestDestroyed.

 Well, you only care about requests that actually create sessions, so
 the first request is not really relevant. Or do you mean that the
 request listener gets the event /before/ the session is created. Hmm.


Exactly. Its also logical to me, that this happens this way, because at the
moment of request creation of the first request noone called
getSession(true) yet.

regards
Leon



  The request that occur simultaneously in chrome(only) are
  pictures and js, replied with 304:
 
  1. Request URL:
  http://localhost:8080/moskitodemo/js/wz_tooltip.js 2. Request
  Method: GET 3. Status Code: 304 Not Modified 4. Request
  Headersview source 1. Accept: */* 2. Accept-Encoding:
  gzip,deflate,sdch 3. Accept-Language: en-US,en;q=0.8 4.
  Cache-Control: max-age=0 5. Connection: keep-alive 6. Cookie:
  JSESSIONID=71474A695869D2494E2135CBCEAF 7. Host:
  localhost:8080 8. If-Modified-Since: Sat, 27 Apr 2013 21:49:44
  GMT 9. If-None-Match: W/35082-1367099384000 10. Referer:
  http://localhost:8080/moskitodemo/mui/mskShowAllProducers 11.
  User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_3)
  AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.65
  Safari/537.36 5. Response Headersview source 1. Date: Mon, 29 Apr
  2013 14:24:36 GMT 2. ETag: W/35082-1367099384000 3. Server:
  Apache-Coyote/1.1
 
 
  Even, the requests are keepalived they look to me as if they were
  executed parallel. At least from the chrome timeline. But its
  hard to tell without further investigation.

 Yeah, you might have to use a packet-sniffer.

 - -chris
 -BEGIN PGP SIGNATURE-
 Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
 Comment: GPGTools - http://gpgtools.org
 Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

 iQIcBAEBCAAGBQJRfomfAAoJEBzwKT+lPKRY89cQAJjLc/xH++tfrNubd9eE+3s3
 UKI5prfRYogHXsXzUG/sB1GS2Gpii+6Qtzuen+/9eHp9zfirKWpWFhk2yPQi1MTz
 oyXQmrXOlYtKwg9iX7FQnkrHfzXbT3Qx5vzrHemf4uwOBhZ9SyutzJsomeHi8Ev0
 B7VMZoKz+APyDLQvCyEYKrJpFwtTcD18RaknUKQzgYxFafh98jL6J0icyv3gq9JW
 MJdl1VSgY0SdkoYitAmDE4Z0qQ9pV6QbS7z4W0VBC9UzxwsG6c+c94ncz3G4WKaa
 mTNvY7SO/PR/z7FNbfo9AO6pvCZ+5SGnxoQ6C99BdJ/Eo8F78tSVR36H7IC5gNKz
 rDJN5tLkCIRcWz3KHeqstL4EnB7FyO838bSamKdOExAEa5+zZCREf8T9D4L6dcCb
 s+bxB+j/fJKSIRXkfiqNozIJ+uwPmr1P/vEqiWEjEVdMJEo2ByTK4Jnx8FJcAi99
 sgVLK0fTH+7J85sSArF2zatZO8LxPE860rNR2CbU/NeeXI1MhxlJnGgPd6jIuOtA
 8QA17rilYIOWp4icQOqubS2j4g3HmpgMDGnoD59DDJRN5odUPQEDzYYD04XjjeQp
 VZFSUdThfxSIzp4CBLmHXTiHXMkgflu5MF0aq0oa6T0eU6SNXkoAr7TC4wB/sHNR
 2JCE36iSziLeIJHKTgmQ
 =W8Ia
 -END PGP SIGNATURE-

 -
 To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
 For additional commands, e-mail: users-h...@tomcat.apache.org




RE: Java Applet can not communicate with Java Servlet

2013-04-29 Thread Caldarale, Charles R
 From: Christopher Schultz [mailto:ch...@christopherschultz.net] 
 Subject: Re: Java Applet can not communicate with Java Servlet

 The servlet spec says that all servlets need to be in a package.

No, it doesn't - but it's still a good idea.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY 
MATERIAL and is thus for use only by the intended recipient. If you received 
this in error, please contact the sender and delete the e-mail and its 
attachments from all computers.


-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Re: getting the request that created the session

2013-04-29 Thread Howard W. Smith, Jr.
Leon,

On Mon, Apr 29, 2013 at 11:02 AM, Leon Rosenberg
rosenberg.l...@gmail.comwrote:

 Hello Howard,
 the sniffer thing has nothing to do with original topic, I was just
 wandering that some requests were having session marked as new, which
 actually shouldn't be the case. Or in other word, the naive understanding
 of session.isNew method is that it should only return true once. But it did
 to it multiple times. The was strange, and christopher and myself were
 talking about investigating it further.


Okay/understood.

Back to your question, filter is ok, too many filters are making stack
 traces fuller than needed, and the order of the filter could be a problem.
 Listener is asked _before_ anything happens.


Good point(s).

About how many filters are you trying to consolidate by using this approach?

I have seen recommendations of adding filters for file types, filters for
login/session-management, etc... I have taken those concepts and put those
in one filter which I have implemented and maintain and have done my best
to ensure that it is 'thread-safe' as well. Some months ago, I reported an
issue to tomcat JIRA/issue list, and those guys shot down my filter and
said that it is not thread-safe. Since then, I have made some code changes
in the filter and related sources (referenced by the filter), and did my
best to make sure it is more threadsafe, even did some research on
thread-safe filters (when injecting via CDI), etc...

also, I am using OmniFaces gzip filter. To my knowledge, that is 2 filters
in my app, that I see in stacktrace, when I have issues to
troubleshoot/debug. When I am debugging, I often wonder why 'filter' show
up all the time in stacktrace, but then of course, I have to remember that
every user/HTTP request has to pass through the filter. So, okay, moving
forward, ignore the fact that the (only) filter(s i have in my app) showed
up in the stacktrace.



 regards
 Leon


 On Mon, Apr 29, 2013 at 4:59 PM, Howard W. Smith, Jr. 
 smithh032...@gmail.com wrote:

  On Mon, Apr 29, 2013 at 10:54 AM, Christopher Schultz 
  ch...@christopherschultz.net wrote:
 
   -BEGIN PGP SIGNED MESSAGE-
   Hash: SHA256

Even, the requests are keepalived they look to me as if they were
executed parallel. At least from the chrome timeline. But its
hard to tell without further investigation.
  
   Yeah, you might have to use a packet-sniffer.
  
  
  definitely sounds like overkill. how much code you need to write for
 such a
  thing, all because one would want to avoid using a filter???
 



Re: getting the request that created the session

2013-04-29 Thread Leon Rosenberg
Hello Howard et al,


On Mon, Apr 29, 2013 at 5:55 PM, Howard W. Smith, Jr. 
smithh032...@gmail.com wrote:

 Leon,

 On Mon, Apr 29, 2013 at 11:02 AM, Leon Rosenberg
 rosenberg.l...@gmail.comwrote:

 Back to your question, filter is ok, too many filters are making stack
  traces fuller than needed, and the order of the filter could be a
 problem.
  Listener is asked _before_ anything happens.
 

 Good point(s).

 About how many filters are you trying to consolidate by using this
 approach?

 I have seen recommendations of adding filters for file types, filters for
 login/session-management, etc... I have taken those concepts and put those
 in one filter which I have implemented and maintain and have done my best
 to ensure that it is 'thread-safe' as well. Some months ago, I reported an
 issue to tomcat JIRA/issue list, and those guys shot down my filter and
 said that it is not thread-safe. Since then, I have made some code changes
 in the filter and related sources (referenced by the filter), and did my
 best to make sure it is more threadsafe, even did some research on
 thread-safe filters (when injecting via CDI), etc...

 also, I am using OmniFaces gzip filter. To my knowledge, that is 2 filters
 in my app, that I see in stacktrace, when I have issues to
 troubleshoot/debug. When I am debugging, I often wonder why 'filter' show
 up all the time in stacktrace, but then of course, I have to remember that
 every user/HTTP request has to pass through the filter. So, okay, moving
 forward, ignore the fact that the (only) filter(s i have in my app) showed
 up in the stacktrace.


Whether you want to have multiple filters or not is a decision based on
your coding guidelines, architectural principles and what not.
Since you are the only user of your filters, it's free to you to use as
many (or few) filter as possible. Personally I would like to separate by
concerns and have multiple filters, because it makes it easier to use,
maintain and test. But this is personal opinion.
However, in my case, I am developing a library that is used by others in
their projects (http://moskito.anotheria.net). It comes already with 8
filters (
http://server04.test.anotheria.net:8080/moskitodemo/mui/mskShowProducersByCategory?pCategory=filter)
and this is a lot. Of course the end user (developer) only chooses the
filters he needs, and not everyone needs everything. However, since its a
lib, you don't want it to show up in your stack traces every request, you'd
rather forget, that you have it at all. Therefore I'm trying to choose a
less visible approach ;-) Also it's easier to add one listener to web.xml
as to add a listener AND a filter. And I need the listener, to know when
sessions expire anyway ;-)
But again, your situation is obviously different from mine ;-) But if you
want to count sessions and all the other funny stuff, give moskito a
chance:

https://confluence.opensource.anotheria.net/display/MSK/HowTo+embed+MoSKito+WebUI+into+a+maven+built+war
https://confluence.opensource.anotheria.net/display/MSK/Integration+Guide

regards
Leon





  regards
  Leon
 
 
  On Mon, Apr 29, 2013 at 4:59 PM, Howard W. Smith, Jr. 
  smithh032...@gmail.com wrote:
 
   On Mon, Apr 29, 2013 at 10:54 AM, Christopher Schultz 
   ch...@christopherschultz.net wrote:
  
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA256
 
 Even, the requests are keepalived they look to me as if they were
 executed parallel. At least from the chrome timeline. But its
 hard to tell without further investigation.
   
Yeah, you might have to use a packet-sniffer.
   
   
   definitely sounds like overkill. how much code you need to write for
  such a
   thing, all because one would want to avoid using a filter???
  
 



Re: getting the request that created the session

2013-04-29 Thread Howard W. Smith, Jr.
On Mon, Apr 29, 2013 at 12:55 PM, Leon Rosenberg
rosenberg.l...@gmail.comwrote:


 Whether you want to have multiple filters or not is a decision based on
 your coding guidelines, architectural principles and what not.
 Since you are the only user of your filters, it's free to you to use as
 many (or few) filter as possible. Personally I would like to separate by
 concerns and have multiple filters, because it makes it easier to use,
 maintain and test. But this is personal opinion.
 However, in my case, I am developing a library that is used by others in
 their projects (http://moskito.anotheria.net). It comes already with 8
 filters (

 http://server04.test.anotheria.net:8080/moskitodemo/mui/mskShowProducersByCategory?pCategory=filter
 )
 and this is a lot. Of course the end user (developer) only chooses the
 filters he needs, and not everyone needs everything. However, since its a
 lib, you don't want it to show up in your stack traces every request, you'd
 rather forget, that you have it at all. Therefore I'm trying to choose a
 less visible approach ;-) Also it's easier to add one listener to web.xml
 as to add a listener AND a filter. And I need the listener, to know when
 sessions expire anyway ;-)
 But again, your situation is obviously different from mine ;-) But if you
 want to count sessions and all the other funny stuff, give moskito a
 chance:


 https://confluence.opensource.anotheria.net/display/MSK/HowTo+embed+MoSKito+WebUI+into+a+maven+built+war
 https://confluence.opensource.anotheria.net/display/MSK/Integration+Guide


Agreed-and-understood on all points. I am definitely interested in a better
approach to managing/monitoring sessions in my web app (that is why i find
this thread interesting), but ATM, my current session-management/monitoring
implementation meets /my/ requirements.

If/when I get a moment (or some bandwidth), I may take a look at your what
you have developed. Thanks.

regards,
Howard