How to dispatch HTTP requests from a servlet to an external server?
Hi every one. I'm trying to make 2 different machine collaborate. Here is the deal: The client request first hit my Servlet, then should be dispatched to a physically distant machine to be analyzed, then my Servlet should read the response of this second server, and finally send response to client. My first idea was to use something like Apache httpclient, or anyway, writing a java HTTP client allowing my servlet to send GET request before returning httpResponse. I wonder if there were other better solutions, which could be more RequestDispatcher-like. Thanks -- Albrecht ANDRZEJEWSKI Créateur - Incubateur Technologique SITE-EERIE - Parc scientifique G. Besse 30035 Nîmes Cedex 1 - France Tel : 04 66 38 40 65 Fax : 04 66 38 70 99* Ce message a ete envoye par le serveur IMP de l'EMA. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: external folder be mapped to Tomcat 'specific 'webapplication'
Folder : /root/images Web application folder : /root/TOMCAT6018 / webapps / XYZAPPS Question Can a external folder be mapped to Tomcat 'specific 'web application' only as shown below If a folder is external, why should it be considered as part of the webapp context ? A popular reason why tomcat administrators used Apache httpd as a frontend to tomcat was (i said was, because it seems to be another cup of tea with today's server performance) to allow serving static content like images, without having a slower process using java for a simple GET over static files. Accesing your /root/images with your webapp URL over the internet can be made: - using url rewriting techniques (mod_rewrite or tomcat filter) - by including this folder to your web app (!) so it becomes an internal webapp folder - by setting up an apache frontend which declare a virtual host redirecting all 'http://IP:PORT/images/' to the document root /root/images and passing all other request to mod_proxy or mod_jk. - perhaps by putting a symbolic link (ln -s) to your image folder within your webapp directory ? Regards, i hope this answer brings you help. Ps: i wouldn't use my root account to store my webapp or web content...neither to run an application server. -- Albrecht ANDRZEJEWSKI Créateur - Incubateur Technologique SITE-EERIE - Parc scientifique G. Besse *** http://haveacafe.wordpress.com Ce message a ete envoye par le serveur IMP de l'EMA. - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Tomcat default encoding character ? Dfile.encoding option mean ?
I ran accros the ml archives, and i find some useful posts. I've almost solved my problem: i can now display the accent (é è à) using request.setCharacterEncoding(UTF-8); response.setCharacterEncoding(UTF-8); It seems that the default charset for tomcat is ISO 8859 1 The j2ee javadoc says: If no charset is specified, ISO-8859-1 will be used. I was pretty sure that tomcat handles UTF-8 by default, but it's not the case...at least for HttpServletResponse objects. Anyway, do you know if it's possible to set up a default charset for the wjole tomcat response, instead of calling these two methods every time a request reach the servlet... ? I tried to define the CATALINA_OPTS, but perhaps the file encoding is different from the request/response encoding. CATALINA_OPTS=-Dfile.encoding=UTF-8 export LC_ALL CATALINA_OPTS -- Albrecht ANDRZEJEWSKI Créateur - Incubateur Technologique SITE-EERIE - Parc scientifique G. Besse *** http://haveacafe.wordpress.com/ Ce message a ete envoye par le serveur IMP de l'EMA. - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: application deployment issue, Tomcat 5.5
Considering my own occasional sniping at Chuck here, it kills me to have to say this, but I don't want anyone to look falsely in the wrong direction maybe. One particularity of this Tomcat 5.5 on platform B, compared to the others, is that it was set up via the standard Linux Debian package mechanism, which kinda puts links all over the place. The error below seems to indicate an error even opening the WAR file though, so I don't know if that can cause the problem we see. java.util.zip.ZipException: error in opening zip file at java.util.zip.ZipFile.open(Native Method) at java.util.zip.ZipFile.init(ZipFile.java:203) I'm not Chuck, and i'm not a tomcat expert, but according to your server configuration and as far as i understand these 3 lines from your log, java is looking to some native code to unzip the WAR file, which is huffman's compressed (yes, war files can be unzipped). I had recently to configure a Debian (etch) production server and i had to manually install the zip and unzip debian package (only gunzip was installed out of the box). (But anyway i choosed to install tomcat from the official apache tomcat server, instead of the Debian package - no time to check and compare their modifications to the 100% original binary distribution.) Regards, -- Albrecht ANDRZEJEWSKI Créateur - Incubateur Technologique SITE-EERIE - Parc scientifique G. Besse -- http://haveacafe.wordpress.com Ce message a ete envoye par le serveur IMP de l'EMA. - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Tomcat migration from T5 to T5.5 mail
I've written this step by step recipe, tested with my tomcat 5.5. You could follow up these instructions and mail sending should work. http://haveacafe.wordpress.com/2008/09/26/113/ Otherwise, can you post your context.xml ? Btw, according SUN's informations, activation.jar is part of the jdk 6, so if you have a recent java version, you don't need it anymore (tomcat doc should be updated). javax.mail.NoSuchProviderException: smtp at javax.mail.Session.getService(Session.java:760) It doesn't sound like having double library. Are you sure your smtp mail server is correctly configured ? (test it whith a commadline using sendmail or whatever). -- Albrecht ANDRZEJEWSKI Créateur - Incubateur Technologique SITE-EERIE - Parc scientifique G. Besse *** http://haveacafe.wordpress.com/ Ce message a ete envoye par le serveur IMP de l'EMA. - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Tomcat migration from T5 to T5.5 mail
Any idea? Your configuration all looks good. Which version of Tomcat are you running? Are you sure there isn't another copy of mail.jar hanging around? What happens if you remove the one you are using? Mark It sounds right, Mark. Although i have said that it wasn't double mail.jar error, it could be that. I experienced putting twice the mail.jar in the server commoon lib and in the webapp libs, and it gives a class cast exception. But having more than one mail library available for mail package can produce this NoSuchProviderException:smtp so. http://forums.sun.com/thread.jspa?messageID=4111277 http://confluence.atlassian.com/display/DOC/Cannot+send+email+due+to+'javax.mail.NoSuchProviderException'+SMTP+error Check also for commons-email-1.0.jar... -- Albrecht ANDRZEJEWSKI Créateur - Incubateur Technologique SITE-EERIE - Parc scientifique G. Besse 30035 Nîmes Cedex 1 - France -- http://haveacafe.wordpress.com Ce message a ete envoye par le serveur IMP de l'EMA. - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Tomcat migration from T5 to T5.5 mail
Quoting AlexM3 [EMAIL PROTECTED]: Hello, Here is the result of a find in the tomcat5.5 directory # find /usr/local/tomcat5.5_svh/ -name *mail* /usr/local/tomcat5.5_svh/common/lib/mail.jar # Is there any path that Tomcat could be loading? Check for smtp.jar too (i don't know if you use it). Other path are your own classpath and environment variable such as PATH, etc... tomcat startup is echoing the path looked at when you call startup.sh. If I move mail.jar out of $CATALINA_HOME it says the same: javax.mail.NoSuchProviderException: No provider for smtp at javax.mail.Session.getProvider(Session.java:433) at javax.mail.Session.getTransport(Session.java:627) ... You said : It works before, and code has and won't be changed, but are you trying using the same javamail API version as in you previous working configuration ? Moreover,i suggest you to call session.setDebug(true) on you session object, so that you will have more verbose debugging output! You wil be able to trace mail.jar initialisation. ref: http://java.sun.com/products/javamail/FAQ.html#debug -- Albrecht ANDRZEJEWSKI Créateur - Incubateur Technologique SITE-EERIE - Parc scientifique G. Besse 30035 Nîmes Cedex 1 - France -- http://haveacafe.wordpress.com Ce message a ete envoye par le serveur IMP de l'EMA. - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
How to manually undeploy a webapp in tomcat ?
Hi everyone, My question is simple: when i was upgrading a webapp, i used to stop tomcat, replace my old war file with the new one using some unix command, and re start the tomcat server. But i noticed that the files under /catalina_home/work/Catalina/localhost/nameofwebapp/ are not updated when tomcat redeploy the new war file, causing my context.xml to be deprecated. It is especially unfair because my context.xml contain my jndi ressources, and it cannot more access neither the mail, neither the database... Is there any proper solution to undeploy manually a webapp ( i don't want to use the manager webapp). And I don't know how to use Ant - so i would prefer a unix-shell-only solution. I think about deleting all the files under /Catalina/localhost/nameofwebapp/ but i'm afraid to miss something. Thanks. -- Albrecht ANDRZEJEWSKI Créateur - Incubateur Technologique SITE-EERIE - Parc scientifique G. Besse Ce message a ete envoye par le serveur IMP de l'EMA. - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Disabling the sessions
[EMAIL PROTECTED] a écrit : is there any way to turn off the jsessionid (disabling the rewriting URL) ? Hi jeanlouis, If you choose to have a cookie session mechanism only, you should track your session with the cookie methods. If you want exclude the url method, you won't be able to track session if cookie are disabled. So the answer depends on your needs ! If session mechanism is not critical for your noncookie users, juste redirect them whhitout the encodeURL method, or override this method to do nothing, and ommit the session-id parameter. Regards, -- Albrecht ANDRZEJEWSKI Créateur - Incubateur Technologique SITE-EERIE - Parc scientifique G. Besse 30035 Nîmes Cedex 1 - France Tel : 04 66 38 40 65 Fax : 04 66 38 70 99* Ce message a ete envoye par le serveur IMP de l'EMA. - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: tomcat iptables problem
Quoting Dieter Schicker [EMAIL PROTECTED]: With this configuration I have the following behavior: Tomcat needs 3 minutes to shut down and another 3 minutes to start up again. If it runs it runs perfectly ... Any ideas? It can occurs if you are working with a localhost url... If you do, just check your tomcat log If you had this error: java.net.UnknownHostException: localhost then take a look to you /etc/hosts to declare it properly ! but you have to know you would obtain a better help if you provide your tomcat log... Ce message a ete envoye par le serveur IMP de l'EMA. - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Basic question - Ingterating Tomcat with Apache
Quoting Peter Crowther [EMAIL PROTECTED]: What are you doing that doesn't just need a vanilla Tomcat? Peter... I plan to have a box, and I just think about pro and cons... I think tomcat stand alone is - easier to deploy. And that's all. I think apache as a front end is a more flexible and secure solution. - if apache fails, tomcat is not affected - if tomcat fails, apache can redirect request to another tomcat - when you serve static content juste like image of your site and all static text part , javascripts, etc ( i mean... dynamic content is often just an hour ticking at the top of the page!) apche can better handle the request and serve them quickier (with cache). Am i wrong ? As i have currently nothing pre-installed on it... and it would be fine to know what you are thinking about it. You seem to be pro vanilla tomcat... But just let us know WHEN pure tomcat has to be choosen ! I need an expert point of view, so tell us about what you experienced ! Thanks :-) Ce message a ete envoye par le serveur IMP de l'EMA. - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: session timeout
Quoting Pierre Goupil [EMAIL PROTECTED]: Hello all ! I'm using a Tomcat-based authentication. How do you do to set the session timeout time ? I mean, the time of inactivity after which one the user must re-login. You can set the http session-time into the Web.xml file of you webapp: session-config session-timeout Your_value_in_minutes /session-timeout /session-config you can set it programmatically to (have a look to the j2ee javadoc) Goupil, c'est un nom prédestiné pour l'informatique ca ;-) Ce message a ete envoye par le serveur IMP de l'EMA. - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Defining data-sources in tomcat
3) In my servlet init(), I lookup the data-source. Each lookup essentially instantiates an instance of the data-source. So a connection pool gets instantiated in each servlet's init. Now it doesn't make sense to create a new connection pool in each servlet. So I'd like to create a single connection pool that will be used by all servlets. I've been looking thru the tomcat docs, to see where I could create this central resource for my webapp. The only option I've seen so far is to create my own life-cycle listener for my webapp. That way I can create a connection pool on start-up. I was wondering if there was a better way to do this ? It's actually your container which create the connection pool and not your servlet. What you do when you are looking up is just finding a reference to the pre-existing datasource. So don't worry and please do not write your own lifecycle :-) Regards, Ali. Ce message a ete envoye par le serveur IMP de l'EMA. - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Retrieve list of all sessions
I actually track my connected users with this code: public class MySessionManager{ public static Set String connecteds; /** Creates a new instance of MySessionManager */ public MySessionManager() { connecteds = new java.util.HashSet(); and i use this method to add an entry for each new session created public void valueBound(HttpSessionBindingEvent httpSessionBindingEvent) { connectedPlayers.add((String)httpSessionBindingEvent.getSession().getAttribute(login)); } I'm new to J2EE/servlet and i have not tested with multiple users, and i was not thinking about the concurrency. Do i need to instantiate my set with something like: Collections.synchronizedSet( new java.util.HashSet()) Or is it better to use directly the old hashtable ? Best regards. Quoting Glen Vermeylen [EMAIL PROTECTED]: We use Tomcat 5.5.20. I actually have no synchronization in place whatsoever. I will change to hashtable and see if it solves the problem. Thank you. 2007/3/7, Caldarale, Charles R [EMAIL PROTECTED]: From: Glen Vermeylen [mailto:[EMAIL PROTECTED] Subject: Retrieve list of all sessions I've created a management screen which lists all currently logged in users. This list is kept as a hashmap and is kept in sync with reality in the following way: A HashMap is unsynchronized; does your logic provide the necessary synchronization for insertions, deletions, *and* retrievals? If not, switching to a HashTable might resolve your problem. Or then again, it might just be a bug, but you didn't tell us the version of Tomcat you're using, so searching bugzilla would be rather tedious. - 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 start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] Ce message a ete envoye par le serveur IMP de l'EMA. - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Tomcat mysteriously shuts down
There is a port used to shutdown the server... This kind line in server.xml: Server port=8005 shutdown=SHUTDOWN debug=0 Perhaps someone is using this ? Quoting Nadav Steindler [EMAIL PROTECTED]: When my servlet isn't sent any requests for about 15 minutes, tomcat shuts down. In particular: 1) The Tomcat process no longer appears when I do ps 2) The catalina.out ends with: Feb 14, 2007 2:12:38 PM org.apache.coyote.http11.Http11Protocol pause INFO: Pausing Coyote HTTP/1.1 on http-9007 Feb 14, 2007 2:12:39 PM org.apache.catalina.core.StandardService stop INFO: Stopping service Catalina Feb 14, 2007 2:12:39 PM org.apache.catalina.core.StandardHostDeployer remove INFO: Removing web application at context path /myservlet Feb 14, 2007 2:12:39 PM org.apache.catalina.core.StandardHostDeployer remove INFO: Removing web application at context path /myservlet2 Feb 14, 2007 2:12:39 PM org.apache.catalina.core.StandardHostDeployer remove INFO: Removing web application at context path /admin Feb 14, 2007 2:12:39 PM org.apache.catalina.logger.LoggerBase stop INFO: unregistering logger Catalina:type=Logger,path=/admin,host=localhost Feb 14, 2007 2:12:39 PM org.apache.catalina.core.StandardHostDeployer remove INFO: Removing web application at context path /webdav Feb 14, 2007 2:12:39 PM org.apache.catalina.core.StandardHostDeployer remove INFO: Removing web application at context path /servlets-examples Feb 14, 2007 2:12:39 PM org.apache.catalina.core.StandardHostDeployer remove INFO: Removing web application at context path /jsp-examples Feb 14, 2007 2:12:39 PM org.apache.catalina.core.StandardHostDeployer remove INFO: Removing web application at context path /balancer Feb 14, 2007 2:12:39 PM org.apache.catalina.core.StandardHostDeployer remove INFO: Removing web application at context path /myservlet3 Feb 14, 2007 2:12:39 PM org.apache.catalina.core.StandardHostDeployer remove INFO: Removing web application at context path /tomcat-docs Feb 14, 2007 2:12:39 PM org.apache.catalina.core.StandardHostDeployer remove INFO: Removing web application at context path /myservlet4 Feb 14, 2007 2:12:40 PM org.apache.catalina.core.StandardHostDeployer remove INFO: Removing web application at context path Feb 14, 2007 2:12:40 PM org.apache.catalina.core.StandardHostDeployer remove INFO: Removing web application at context path /manager Feb 14, 2007 2:12:40 PM org.apache.catalina.logger.LoggerBase stop INFO: unregistering logger Catalina:type=Logger,host=localhost Feb 14, 2007 2:12:40 PM org.apache.catalina.logger.LoggerBase stop INFO: unregistering logger Catalina:type=Logger Feb 14, 2007 2:12:40 PM org.apache.coyote.http11.Http11Protocol destroy INFO: Stopping Coyote HTTP/1.1 on http-9007 What does this mean? Why is it happening? _ Laugh, share and connect with Windows Live Messenger http://clk.atdmt.com/MSN/go/msnnkwme002001msn/direct/01/?href=http://imagine-msn.com/messenger/launch80/default.aspx?locale=en-ussource=hmtagline - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] Ce message a ete envoye par le serveur IMP de l'EMA. - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: get a strange cast error with using the tomcat mail ressource
Quoting Caldarale, Charles R [EMAIL PROTECTED]: java.lang.ClassCastException: javax.mail.Session cannot be cast to javax.mail.Session at utils.MailHelper.sendMail(MailHelper.java:36) This would indicate you've got the javax.mail.Session class in multiple places. Thank you for explaining this. The activation.jar and mail.jar files should go into common/lib only, not in the app's WEB-INF/lib. Check the docs for configuring mail: http://tomcat.apache.org/tomcat-5.5-doc/jndi-resources-howto.html#JavaMa il%20Sessions See the note in item 4. Yes, that's was the mistake (i reinstalled my application with my own bad notes...). I will try to have a better look to the doc the next time. Thx! Ce message a ete envoye par le serveur IMP de l'EMA. - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
get a strange cast error with using the tomcat mail ressource
Hello all, I hope i will not pollute the list, but i'm affraid of being faced with a bug :-( I have to send a mail with tomcat. I followed the instructions of the tomcat documentation, corresponding my version (5.5). Using this code: public static String sendMail(String destinataire, String login){ Session session = null; try { Context initCtx = new InitialContext(); Context envCtx = (Context) initCtx.lookup(java:comp/env); line 36 session = (Session) envCtx.lookup(mail/MonMail); //session = envCtx.lookup(mail/MonMail); } catch (NamingException ex) { System.out.println(erreur au lookup); return ex.getMessage(); } I have the following error that i really dislike : java.lang.ClassCastException: javax.mail.Session cannot be cast to javax.mail.Session at utils.MailHelper.sendMail(MailHelper.java:36) I use the netbeans 5.5 bundled tomcat server (v 5.5.17) on the 1.6 java version (but source level set to 1.5). Do you think it's me ? Or a bug of the IDE ? or a bug of tomcat ? I previously used this code with the same config in a successful way with another tomcat 5.5 server. I'm getting crazy with this awful and strange cast error :-( If only someone could help... I join the web.xml tag: resource-ref description Resource reference to a factory for javax.mail.Session instances that may be used for sending electronic mail messages, preconfigured to connect to the appropriate SMTP server. /description res-ref-namemail/MonMail/res-ref-name res-typejavax.mail.Session/res-type res-authContainer/res-auth /resource-ref and my server.xml Resource name=mail/MonMail type=javax.mail.Session mail.smtp.host=smtp.free.fr/ and my context.xml Resource name=mail/MonMail auth=Container type=javax.mail.Session mail.smtp.host=smtp.free.fr/ Hope to hear soon from the list about this problem :-( Best regards. Ce message a ete envoye par le serveur IMP de l'EMA. - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]