RE: Giving access to an html file in tomcat
IE uses some voodoo logic to decide when to show it's own error page or not. Anytime it get's something other than a HTTP 200 or 302, it looks at the HTML returned with it, and if it seems to be a well-formed html doc, and/or exceeds a certain length, then it will show that HTML, else it decides to show it's own Friendly HTTP Error page ( which IMHO is completely useless to experienced and novice users alike, but that's beside the point ). You can turn off this behaviour in Tools-Internet Options-Advanced-Browsing-Show Friendly HTTP Error Messages And this will at least show you exactly what you are returning to the browser. Steph -Original Message- From: Bender, Christopher [mailto:[EMAIL PROTECTED] Sent: Monday, December 08, 2003 3:40 PM To: Tomcat Users List Subject: Giving access to an html file in tomcat Hey, I have added the following to my web.xml of one of my web apps: error-page error-code403/error-code location/error/error.htm/location /error-page When I try and test this (go to a page I do not have access to that will throw a 403 error), i get the Internet Explorer error page that says You might not have permission to view this directory or page using the credentials you supplied and not my page (and not even a tomcat page). Am I missing some configuration somewhere? - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Relationship between server.xml/Resource and web.xml/resource-ref.
Thanks Chris, but here is the part I don't exactly understand : The webapp signifies its desire to use that resource by including a complimentary resource-ref section in the deployment descriptor. A webapp ( at least under tomcat 4.1 ) does not require the resource-ref section to be in place, for it to use a jndi resource that is already defined in a resource section of it's context element. Is Tomcat just being nice about this ? Or is the point on the resource-ref to inform the container at deployment time, that the webapp requires such a resource to exist ? I think that's what the servlet spec is saying, but the English is a little muddled : These developer uses these elements describe certain objects that the web application requires to be registered in the JNDI namespace in the web container at runtime -Original Message- From: Christopher Schultz [mailto:[EMAIL PROTECTED] Sent: Wednesday, November 19, 2003 8:31 AM To: Tomcat Users List Subject: Re: Relationship between server.xml/Resource and web.xml/resource-ref. Florian, Is it completely up to the developers/deployers wether the necessary resources get declared in the server or in the application? This is correct. Is it just for convenience, so that deployer doesn't have to unpack the WAR? No, this has nothing to do with unpacking WAR files. Or -- like someone stated on this list (to my confusion) -- that the server.xml Resource element and the web.xml resource-ref have a relation that is similar to that of an implementation class instance and an interface? This is an apt analogy. The server.xml sets up the actual resource (often in the GlobalNamingResources section), then allows the application to use it (by adding a ResourceLink section in the Context where you want to use it). The webapp signifies its desire to use that resource by including a complimentary resource-ref section in the deployment descriptor. -chris - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
WebappClassLoader won't load resource from jar file ?!?
I have a web app containing resource files in several jar files, but I am unable to access the resources at runtime unless they are exploded into the classes directory. When trying to access the resource files using ClassLoader.getResourceAsStream( /meta-inf/com/kvasar/data.xml ) I always get null returned, even though that resource does exist inside a jar file in the web app's WEB-INF/lib directory. If I extract that resource to the classes directory, so I now have WEB-INF/classes/meta-inf/com/kvasar/data.xml, then I get it fine using the exact same path and ClassLoader - it works fine. The Tomcat Class Loader HOW-TO is telling me that it should find it in the jar. I have this problem on Tomcat 4.0.1 4.1.24, Win 2K The ClassLoader instance I am using for the getResourceAsStream() calls, is one that I get from one of my classes that is deployed to my webapp in a war file. Logging a toString() on this ClassLoader is shown below. Is it meaningful that it doesn't list my jar files in it's list of repositories ?? --- WebappClassLoader available: delegate: false repositories: /WEB-INF/classes/ required: -- Parent Classloader: StandardClassLoader available: Extension[javax.mail, implementationVendor=Sun Microsystems, Inc., implementationVendorId=com.sun, implementationVer sion=1.2, specificationVendor=Sun Microsystems, Inc., specificationVersion=1.2] delegate: true repositories: file:C:\Tomcat.4.0-retired\classes\ file:C:\Tomcat.4.0-retired\lib\activation.jar file:C:\Tomcat.4.0-retired\lib\catalina.jar file:C:\Tomcat.4.0-retired\lib\jakarta-oro-2.0.2-dev-2.jar file:C:\Tomcat.4.0-retired\lib\jakarta-regexp-1.2.jar file:C:\Tomcat.4.0-retired\lib\mail.jar file:C:\Tomcat.4.0-retired\lib\mailet.jar file:C:\Tomcat.4.0-retired\lib\xml4j.jar required: -- Parent Classloader: StandardClassLoader available: Extension[javax.mail, implementationVendor=Sun Microsystems, Inc., implementationVendorId=com.sun, implementationVer sion=1.2, specificationVendor=Sun Microsystems, Inc., specificationVersion=1.2] delegate: true repositories: file:C:\Tomcat.4.0-retired\common\classes\ file:C:\Tomcat.4.0-retired\common\lib\activation.jar file:C:\Tomcat.4.0-retired\common\lib\jasper-compiler.jar file:C:\Tomcat.4.0-retired\common\lib\jasper-runtime.jar file:C:\Tomcat.4.0-retired\common\lib\jta.jar file:C:\Tomcat.4.0-retired\common\lib\mail.jar file:C:\Tomcat.4.0-retired\common\lib\naming-common.jar file:C:\Tomcat.4.0-retired\common\lib\naming-factory.jar file:C:\Tomcat.4.0-retired\common\lib\naming-resources.jar file:C:\Tomcat.4.0-retired\common\lib\pbclient.jar file:C:\Tomcat.4.0-retired\common\lib\servlet.jar file:C:\Tomcat.4.0-retired\common\lib\tools.jar file:C:\Tomcat.4.0-retired\common\lib\tyrex-0.9.7.0.jar required: -- Parent Classloader: [EMAIL PROTECTED] Help ! Thanks ! Steph - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Problem with ConnectionPool on Linux
My guess is you have some kind of job that runs at night that kicks or restarts your dB server ?? See if restarting your MySQL server in the middle of the day produces the same results. Anyway to make DBCP tolerant of the database dissapearing, try adding autoReconnect=true to your jdbc url. As in : jdbc:mysql://127.0.0.1:3306/mydb?autoReconnect=true -Original Message- From: Veselin Kovacevic [mailto:[EMAIL PROTECTED] Sent: Tuesday, November 11, 2003 4:57 AM To: [EMAIL PROTECTED] Subject: Problem with ConnectionPool on Linux Hi, I have o problem with Tomcat 4.1.24 on SuseLinux7.3. Our application has Controller servlet (below) where using connection objects from connection pool. When tomcat started, application working fine and everything OK that day. But next day when we try to start application we get error message in isUser method (PortalUserDB class). It's first place where we use connection object in application. Method isUser is very simple method for authenticate user (below). We get this exception: SQL Exception:java.sql.SQLException: No operations allowed after connection closed Connection object is not null in this case, and this message for me is not correct. Next, if I restart tomcat, everything working ok... (for next day). On windows (we using windows for development platform) we have not this problem. What is problem? Is configuration server.xml or similar configuration files on Linux different rather on windows? Note: On both platform we using Tomcat 4.1.24 and j2sdk1.4.1_03. public class Controller extends HttpServlet { private DataSource ds; public void init(ServletConfig config) throws ServletException { super.init(config); try { InitialContext initCtx = new InitialContext(); Context envCtx = (Context)initCtx.lookup(java:comp/env); ds = (DataSource)envCtx.lookup(jdbc/MySQLPool); } catch (Exception e){ throw new UnavailableException(e.getMessage()); } } public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { request.setCharacterEncoding(iso-8859-2); if (ds != null) { Connection conn = ds.getConnection(); if (conn != null) { boolean isUserExists = PortalUserDB.isUser(conn, userName, userPass); conn.close(); } } } public static boolean isUser(Connection conn, String userName, String userPass) throws SQLException, IOException { String query = SELECT user_name FROM admin_user + WHERE user_name = ? + AND user_pass = ?; boolean isUserExists = false; try { PreparedStatement pstmt = conn.prepareStatement(query); pstmt.setString(1, userName); pstmt.setString(2, userPass); ResultSet rs = pstmt.executeQuery(); isUserExists = rs.next(); rs.close(); rs = null; pstmt.close(); pstmt = null; } catch (SQLException sqle) { PortalLog.addLogLine(Class: PortalUserDB, Method: isUser. SQL Exception: + sqle, userName); } return isUserExists; } Thanks, Veso - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Redirecting HTTP requests to HTTPS
Adding the following lines to your deployment descriptor ( web.xml ) will do the trick : security-constraint web-resource-collection web-resource-nameEntire Application/web-resource-name url-pattern/*/url-pattern /web-resource-collection user-data-constraint transport-guaranteeCONFIDENTIAL/transport-guarantee /user-data-constraint /security-constraint However - Does anyone know how to configure this in server.xml rather than web.xml. I would really be able to configure it on a server by server basis ( e.g. development vs. production machines ). ? Steph -Original Message- From: Raghu Karamel [mailto:[EMAIL PROTECTED] Sent: Tuesday, November 11, 2003 8:49 PM To: [EMAIL PROTECTED] Subject: Redirecting HTTP requests to HTTPS Experts, Need your help!! I have both the HTTP (port 8080) and HTTPS (Port 8443) working with my Tomcat server (Version 3.2.. I believe). So is there any way I can get all the HTTP requests redirected to HTTPS by Tomcat? Something by tweaking the Tomcat configuration files? I do not have an Apache server there to serve Tomcat, otherwise I would have used the mod_rewrite to get that done. Thanks and your help will be appreciated. Raghu - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: tomcat 4.1.27 with jvm 1.4.2_02=crashes
Sorry, not sure which build 1.4.2_02 but I am happily running Tomcat 4.1.27 on Linux RH 9 Win 2K Server SP4, both with Sun's Java 1.4.2-b28 -Original Message- From: David Muller [mailto:[EMAIL PROTECTED] Sent: Monday, November 10, 2003 11:26 AM To: [EMAIL PROTECTED] Subject: tomcat 4.1.27 with jvm 1.4.2_02=crashes Anyone else finding problems with tomcat and the latest j2sdk (1.4.2_02)? We think we may need to go back to 1.4.2_01. -Dave David E. Muller Configuration Manager Overture Services, Inc. www.overture.com Office: 760.476.6406 Mobile: 760.458.2714 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
How to persist web-app properties across restarts ?
I am looking for the most standard and lightweight way to persist some properties about a web application across restarts of the web application or the entire server. Something like the ServletContext.setAttribute() method, but with the persistence ability that you get from Http sessions would be perfect. I am using this for a management servlet that can indicate to load balancing software that traffic needs to be directed away from a given tomcat instance when it's in a certain state, and the management servlet needs to remember what state it was last in when it's application is restarted. Because it's used in monitoring I don't want any dependancies on external data stores other than simple file system. Thanks Steph - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: ant jspc task and tomcat-4.1.24
Yes it is possible. I am currently using it, there was some discussion on this : http://www.mail-archive.com/[EMAIL PROTECTED]/msg100350.html I think your problem may be that you haven't set the compiler=jasper41 attribute in the jspc element, as in : jspc srcdir=${rootdir} destdir=${webapp.workdir} failonerror=false classpathref=jspc_parse.classpath package=org.apache.jsp compiler=jasper41 -Original Message- From: Edson Alves Pereira [mailto:[EMAIL PROTECTED] Sent: Friday, November 07, 2003 2:53 PM To: 'Tomcat-User List' Subject: ant jspc task and tomcat-4.1.24 Does Tomcat-4.1.24 is compatible with Ant-1.5.4´s jspc task? I´m trying to compile some JSP pages but i´m getting this error: D:\desenv\osctrl\buildant Buildfile: build.xml compilar-jsp: [jspc] Compiling 3 source filesD:\tmp\classes-jsp\com\panamericano\osctrl\j sp [jasperc] 2003-11-07 04:51:08 - ERROR-the file '\frmMenu_.jsp' generated the f ollowing general exception: java.lang.NullPointerException [jasperc] error:org.apache.jasper.JasperException: Error compiling \frmMenu_.j sp [jasperc] at org.apache.jasper.JspC.processFile(JspC.java:596) [jasperc] at org.apache.jasper.JspC.execute(JspC.java:801) [jasperc] at org.apache.jasper.JspC.main(JspC.java:823) BUILD FAILED file:D:/desenv/osctrl/build/build.xml:50: Java returned: 9 Total time: 5 seconds - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Deploying a WAR file referenced by a Context configuration .XML file
I'm really interested because you have exactly the setup that I am using in production. Although I'm not sure why you are concerned about how/where the war file get's exploded. In your lingo I use a SHAREDSETUP.xml which explicitly has a context with attribute docbase=/home/appbase/SHAREDSETUP.war This works fine, I just deploy new versions of SHAREDSETUP.war, Tomcat explodes the war somewhere ( TOMCAT_HOME/work/somethingorother ) and the war has access to my DBCP. Another setup I toyed with was configuring the DBCP in the DefaultContext attribute, and then any war file dropped into tomcat should have access to it. -Original Message- From: Larson, Kirk [mailto:[EMAIL PROTECTED] Sent: Friday, November 07, 2003 12:48 PM To: '[EMAIL PROTECTED]' Subject: Deploying a WAR file referenced by a Context configuration .XML file I have an applicaiton which is using a connection pool provided by Tomcat. In order to allow the application to reference the connection pool, I created a Context configuration file for the application and placed it in the webapps directory. The application is called SHAREDSETUP, and I placed two files in the webapps directory ... SHAREDSETUP.WAR and SHAREDSETUP.XML. When I start Tomcat, the WAR file is not automatically expanded and the application is not started because the /sharedsetup directory does not exist. If I delete the SHAREDSETUP.XML file, Tomcat automatically explodes the WAR file and creates the /sharedsetup directory. The application is started fine, however the application is unable to reference the database connection. I need the connection pool, therefore this is not an option. If I manually explode the WAR file, the application is started successfully and everything works fine. However, I was hoping to not have to do this. I have to provide the WAR file to an external group who will be responsible for deploying the application. I wanted to make the deployment procedure as simple as possible. How do I get Tomcat to automatically explode a WAR file if I need to use a Context configuratioin XML file? Thanks, Kirk contents of sharedsetup.xml = Context docBase=sharedsetup cookies=true path=/sharedsetup className=org.apache.catalina.core.StandardContext crossContext=false reloadable=false mapperClass=org.apache.catalina.core.StandardContextMapper useNaming=true debug=0 swallowOutput=false privileged=false wrapperClass=org.apache.catalina.core.StandardWrapper cachingAllowed=true charsetMapperClass=org.apache.catalina.util.CharsetMapper Logger className=org.apache.catalina.logger.FileLogger debug=9 verbosity=1 prefix=localhost_sharedsetup_log. directory=logs timestamp=true suffix=.txt/ ResourceLink name=jdbc/sharedsetup/default global=jdbc/sharedsetup/test/ ResourceLink name=jdbc/sharedsetup/dev global=jdbc/sharedsetup/dev/ ResourceLink name=jdbc/sharedsetup/test global=jdbc/sharedsetup/test/ /Context failure logged when application attempts to start = 2003-11-07 11:00:46 StandardContext[/sharedsetup]: Resources start failed: java.lang.IllegalArgumentException: Document base ..\webapps\sharedsetup does not exist or is not a readable directory at org.apache.naming.resources.FileDirContext.setDocBase(FileDirContext.java:19 3) at org.apache.catalina.core.StandardContext.resourcesStart(StandardContext.java :3342) at org.apache.catalina.core.StandardContext.start(StandardContext.java:3472) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:8 21) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:807) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:579) at org.apache.catalina.core.StandardHostDeployer.addChild(StandardHostDeployer. java:700) at java.lang.reflect.Method.invoke(Native Method) at org.apache.commons.beanutils.MethodUtils.invokeMethod(MethodUtils.java:252) at org.apache.commons.digester.SetNextRule.end(SetNextRule.java:260) at org.apache.commons.digester.Rule.end(Rule.java:276) at org.apache.commons.digester.Digester.endElement(Digester.java:1064) at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source) at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanEndElement(Unknown Source) at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatc her.dispatch(Unknown Source) at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source) at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source) at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source) at org.apache.xerces.parsers.XMLParser.parse(Unknown Source) at
RE: Deploying a WAR file referenced by a Context configuration .XML file
What version of Tomcat are you using? 4.1.27 Mine behaved as you described UNTIL I explicitly referenced the .war file in the docbase attribute. -Original Message- From: Larson, Kirk [mailto:[EMAIL PROTECTED] Sent: Friday, November 07, 2003 2:25 PM To: 'Tomcat Users List' Subject: RE: Deploying a WAR file referenced by a Context configuration .XML file What version of Tomcat are you using? I (stupidly) forgot to mention that I am using Tomcat 4.1. A previous response (by Jacob Kjome) to my question indicated that 4.1.xx of Tomcat behaved exactly as I described. He also stated that Tomcat 5 has the behavior I desired. If you are using Tomcat 5, this would confirm his explanation. -Original Message- From: Steph Richardson [mailto:[EMAIL PROTECTED] Sent: Friday, November 07, 2003 1:15 PM To: Tomcat Users List Subject: RE: Deploying a WAR file referenced by a Context configuration .XML file I'm really interested because you have exactly the setup that I am using in production. Although I'm not sure why you are concerned about how/where the war file get's exploded. In your lingo I use a SHAREDSETUP.xml which explicitly has a context with attribute docbase=/home/appbase/SHAREDSETUP.war This works fine, I just deploy new versions of SHAREDSETUP.war, Tomcat explodes the war somewhere ( TOMCAT_HOME/work/somethingorother ) and the war has access to my DBCP. Another setup I toyed with was configuring the DBCP in the DefaultContext attribute, and then any war file dropped into tomcat should have access to it. -Original Message- From: Larson, Kirk [mailto:[EMAIL PROTECTED] Sent: Friday, November 07, 2003 12:48 PM To: '[EMAIL PROTECTED]' Subject: Deploying a WAR file referenced by a Context configuration .XML file I have an applicaiton which is using a connection pool provided by Tomcat. In order to allow the application to reference the connection pool, I created a Context configuration file for the application and placed it in the webapps directory. The application is called SHAREDSETUP, and I placed two files in the webapps directory ... SHAREDSETUP.WAR and SHAREDSETUP.XML. When I start Tomcat, the WAR file is not automatically expanded and the application is not started because the /sharedsetup directory does not exist. If I delete the SHAREDSETUP.XML file, Tomcat automatically explodes the WAR file and creates the /sharedsetup directory. The application is started fine, however the application is unable to reference the database connection. I need the connection pool, therefore this is not an option. If I manually explode the WAR file, the application is started successfully and everything works fine. However, I was hoping to not have to do this. I have to provide the WAR file to an external group who will be responsible for deploying the application. I wanted to make the deployment procedure as simple as possible. How do I get Tomcat to automatically explode a WAR file if I need to use a Context configuratioin XML file? Thanks, Kirk contents of sharedsetup.xml = Context docBase=sharedsetup cookies=true path=/sharedsetup className=org.apache.catalina.core.StandardContext crossContext=false reloadable=false mapperClass=org.apache.catalina.core.StandardContextMapper useNaming=true debug=0 swallowOutput=false privileged=false wrapperClass=org.apache.catalina.core.StandardWrapper cachingAllowed=true charsetMapperClass=org.apache.catalina.util.CharsetMapper Logger className=org.apache.catalina.logger.FileLogger debug=9 verbosity=1 prefix=localhost_sharedsetup_log. directory=logs timestamp=true suffix=.txt/ ResourceLink name=jdbc/sharedsetup/default global=jdbc/sharedsetup/test/ ResourceLink name=jdbc/sharedsetup/dev global=jdbc/sharedsetup/dev/ ResourceLink name=jdbc/sharedsetup/test global=jdbc/sharedsetup/test/ /Context failure logged when application attempts to start = 2003-11-07 11:00:46 StandardContext[/sharedsetup]: Resources start failed: java.lang.IllegalArgumentException: Document base ..\webapps\sharedsetup does not exist or is not a readable directory at org.apache.naming.resources.FileDirContext.setDocBase(FileDirContext.java:19 3) at org.apache.catalina.core.StandardContext.resourcesStart(StandardContext.java :3342) at org.apache.catalina.core.StandardContext.start(StandardContext.java:3472) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:8 21) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:807) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:579) at org.apache.catalina.core.StandardHostDeployer.addChild(StandardHostDeployer. java
RE: How to persist web-app properties across restarts ?
thanks, but the whole point of this is to persist a property across restarts - whether they be the entire VM or just the web-app. Is there a consistent wat to persist property information for the web-app to the filesystem, in the same way that sessions can be persisted ? I know that the servlet spec requires the ServletContext to provide a tempdir, so I will probably try serializing my properties to a file in that dir. -Original Message- From: Jacob Kjome [mailto:[EMAIL PROTECTED] Sent: Friday, November 07, 2003 2:17 PM To: Tomcat Users List Subject: Re: How to persist web-app properties across restarts ? Put a singleton helper class in a parent classloader such as in shared or common Tomcat classloaders and manipulate collections there. They will exist as long as the JVM (and Tomcat) is running. Otherwise, you should also be able to use stuff like System.setProperty(). Jake At 01:51 PM 11/7/2003 -0500, you wrote: I am looking for the most standard and lightweight way to persist some properties about a web application across restarts of the web application or the entire server. Something like the ServletContext.setAttribute() method, but with the persistence ability that you get from Http sessions would be perfect. I am using this for a management servlet that can indicate to load balancing software that traffic needs to be directed away from a given tomcat instance when it's in a certain state, and the management servlet needs to remember what state it was last in when it's application is restarted. Because it's used in monitoring I don't want any dependancies on external data stores other than simple file system. Thanks Steph - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: servlets and cookies
Randy, Because you are doing an RequestDispatcher.include() the my.jsp page is served up in the same HTTP Response that is setting the cookies. my.jsp then looks in the Request for the cookies and doesn't find them there, because it's looking at the same HTTP Request that was originally sent to your login servlet. All the forwarding here ( or including in this case ) occurs on the server side. You need to do a round trip to the browser to set the cookies, so that they will be included on subsequent requests. i.e. something like : response.sendRedirect( /my.jsp ); This will send a 302 response to the browser, as well as the correct response headers to set your cookie values, so that they are included as request headers in the redirected request to my.jsp Steph P.S. for what it's worth I think the best explanation of all you need to know about HTTP methods, headers, cookies, etc.. comes in the first few chapters of an O'Reilly book called ASP in a Nutshell - just the thing for a Tomcat users list ;) -Original Message- From: Randy Paries [mailto:[EMAIL PROTECTED] Sent: Tuesday, October 14, 2003 3:48 PM To: [EMAIL PROTECTED] Subject: servlets and cookies Hello i assume this is more of a servlet programming problem that tomcat, but i hope someone has some insight? Please tell me i can do this: 1)i go to a jsp page and if it does not find the exist of a cookie it forwards to a login screen 2) the login screen submits to a servlet, and then set some cookies and then forwards to the original JSP 3) the orig jsp sees those cookies and life is fine. well i can not make the servlet set the cookies so that the forwarding jsp sees those cookies. Cookie cookie1 = new Cookie(USERID,_User.getUname()); cookie1.setMaxAge(-1); cookie1.setPath(/); res.addCookie(cookie1); Cookie cookie2 = new Cookie(USERDIR,_User.getDir()); cookie2.setMaxAge(-1); cookie2.setPath(/); res.addCookie(cookie2); RequestDispatcher disp = getServletConfig().getServletContext().getRequestDispatcher(/my.jsp); disp.include(req,res); my.jsp does not see the cookies. if i just refresh the browser the second time in the cookies are there What the heck am i doing wrong thanks - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: redirect port 8080 to 443
Can't think why this is still a problem ( it definitely works for me ) , other than a simple one of URL patterns. Does the URI /secure match the pattern /secure/*, is there a default document there which would cause a redirect that is affecting this. What happens when you try going to http://localhost/secure/somethingelse -Original Message- From: Twan Munster [mailto:[EMAIL PROTECTED] Sent: Monday, October 13, 2003 6:17 AM To: Tomcat Users List Subject: Re: redirect port 8080 to 443 thnx for comment, but it didn't work I still can connect to http://localhost:8080/secure/ Twan - Original Message - From: Steph Richardson [EMAIL PROTECTED] To: Tomcat Users List [EMAIL PROTECTED] Sent: Sunday, October 12, 2003 5:17 PM Subject: RE: redirect port 8080 to 443 You can have tomcat automatically make redirects to https ( and whatever port is configured in the redirectPort attribute of your http Connecter - 443 usually ), you can add some constraints in web.xml. Try this altered for whatever directories you want to be https only : security-constraint web-resource-collection web-resource-nameSome Directories/web-resource-name url-pattern/secure/*/url-pattern url-pattern/checkout/*/url-pattern /web-resource-collection user-data-constraint transport-guaranteeCONFIDENTIAL/transport-guarantee /user-data-constraint /security-constraint Beware now of issues with welcome-file-list redirects happening at the same time as this one. You can end up with situations where tomcat sends you to https on the http port. e.g. : https://myserver.com:8080/secure.index.jsp Steph -Original Message- From: Bill Barker [mailto:[EMAIL PROTECTED] Sent: Saturday, October 11, 2003 12:39 AM To: [EMAIL PROTECTED] Subject: Re: redirect port 8080 to 443 It's in the FAQ: http://jakarta.apache.org/tomcat/faq/security.html#https Twan Munster [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Hello, I'm using apache+mod_ssl+mod_jk to make a secure connection. But every time I call a page in cocoon it is called through port 8080. Is it possible to redirect a call to port 8080 to port 443? And not for the entire server, but only for a certain directory?How is this done? thnx Twan - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Can I read file resources from a .WAR file at runtime ?
I have a web-app that uses several xml, xsd, and other configuration files at runtime ( including during the Application Init event ). We keep these files under various directories under WEB-INF so that we can get their paths at runtime relative to ServletContext.getRealPath( WEB-INF ). When I am deploying this web-app as a war file, I can detect I am a war file at runtime because ( getRealPath( ) == null ), but is there a consistent way to read a file from this war file ? Thanks Steph Richardson Kvasar Technology LLC HQ: suite 106, 822 Boylston st., Chestnut Hill, MA 02467 smtp : [EMAIL PROTECTED] http : www.kvasar.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: redirect port 8080 to 443
You can have tomcat automatically make redirects to https ( and whatever port is configured in the redirectPort attribute of your http Connecter - 443 usually ), you can add some constraints in web.xml. Try this altered for whatever directories you want to be https only : security-constraint web-resource-collection web-resource-nameSome Directories/web-resource-name url-pattern/secure/*/url-pattern url-pattern/checkout/*/url-pattern /web-resource-collection user-data-constraint transport-guaranteeCONFIDENTIAL/transport-guarantee /user-data-constraint /security-constraint Beware now of issues with welcome-file-list redirects happening at the same time as this one. You can end up with situations where tomcat sends you to https on the http port. e.g. : https://myserver.com:8080/secure.index.jsp Steph -Original Message- From: Bill Barker [mailto:[EMAIL PROTECTED] Sent: Saturday, October 11, 2003 12:39 AM To: [EMAIL PROTECTED] Subject: Re: redirect port 8080 to 443 It's in the FAQ: http://jakarta.apache.org/tomcat/faq/security.html#https Twan Munster [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Hello, I'm using apache+mod_ssl+mod_jk to make a secure connection. But every time I call a page in cocoon it is called through port 8080. Is it possible to redirect a call to port 8080 to port 443? And not for the entire server, but only for a certain directory?How is this done? thnx Twan - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Tools for benchmarking profiling Tomcat
Thanks Yoav, I have tried OptimizeIt which does not seem to have the same problem with idle IO time as JProfiler, and so I got much different ( and better ) results. Some tech staff at ej-technologies, told me that the next release of JProfiler in a few months will have a seperate IO state that will take care of this problem. Regards, Steph -Original Message- From: Shapira, Yoav [mailto:[EMAIL PROTECTED] Sent: Monday, August 25, 2003 12:12 PM To: Tomcat Users List Subject: RE: Tools for benchmarking profiling Tomcat Howdy, Second half of this question is what is a good profiler to use with Tomcat I like OptimizeIt. with my current Tomcat install, BUT it's major problem is that it includes time that threads spend idly listening on sockets. So That's proper behavior. I'm not aware of a profiler that magically decided what is and isn't appropriate to profile for your webapp. Well-written tests don't have much idle time in general. I'm also not aware of any profilers that can take an operation ignore list (e.g. socket_read, socket_write) and ignore CPU time spent on those operations. Yoav Shapira This e-mail, including any attachments, is a confidential business communication, and may contain information that is confidential, proprietary and/or privileged. This e-mail is intended only for the individual(s) to whom it is addressed, and may not be saved, copied, printed, disclosed or used by anyone else. If you are not the(an) intended recipient, please immediately delete this e-mail from your computer system and notify the sender. Thank you. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Tools for benchmarking profiling Tomcat
Second half of this question is what is a good profiler to use with Tomcat ? I am currently using JProfiler ( http://www.ej-technologies.com/products/jprofiler/overview.html ) which plugs plays really easily with my current Tomcat install, BUT it's major problem is that it includes time that threads spend idly listening on sockets. So when trying to identify performance hotspots in a server app like tomcat, it becomes very difficult to get a good view of what percentage of time is spent where. I have seen JProf ( http://starship.python.net/crew/garyp/jProf.html ) but I am scared by the use of the terms C++ JFC on the intro page. Any other suggestions - especially for something that will work well with Tomcat understands how to treat time spent in the IO libs. Thanks, Steph -Original Message- From: Steph Richardson [mailto:[EMAIL PROTECTED] Sent: Thursday, August 21, 2003 4:10 PM To: Tomcat Users List Subject: Tools for benchmarking profiling Tomcat I guess this is more of a generic http server question than a tomcat one, but I'm looking for recommended toolset(s) to use in benchmarking the performace of our tomcat based webapps. I'm looking for something like Apache Benchmarking Tool that I could use on windows - preferably free, and preferably a java based thing that I could run elsewhere, and that I could wrap in Ant tasks, and that supports https. Suggestions appreciated. Steph Richardson Kvasar Technology LLC HQ: suite 106, 822 Boylston st., Chestnut Hill, MA 02467 smtp : [EMAIL PROTECTED] http : www.kvasar.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Tools for benchmarking profiling Tomcat
I guess this is more of a generic http server question than a tomcat one, but I'm looking for recommended toolset(s) to use in benchmarking the performace of our tomcat based webapps. I'm looking for something like Apache Benchmarking Tool that I could use on windows - preferably free, and preferably a java based thing that I could run elsewhere, and that I could wrap in Ant tasks, and that supports https. Suggestions appreciated. Steph Richardson Kvasar Technology LLC HQ: suite 106, 822 Boylston st., Chestnut Hill, MA 02467 smtp : [EMAIL PROTECTED] http : www.kvasar.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Installing Tomcat as a Service
Sounds like your problem can be easily solved by reading the manpage, as the previous email from Paul suggests. man chkconfig will tell you exactly why service service-name does not support chkconfig you need specially formatted comments starting with something like # chkconfig : 2345 80 20 -Original Message- From: Stuart Stephen [mailto:[EMAIL PROTECTED] Sent: Wednesday, August 20, 2003 10:57 AM To: Tomcat Users List Subject: RE: Installing Tomcat as a Service Thanks for the reply, I've tried creating a script in the /etc/init.d directory and then running the chkconfig --add script-name and this hasn't worked for me. I'm getting an error saying that: service service-name does not support chkconfig I must still be doing something wrong? The script has the same permissions showing in the ls -l list? -Original Message- From: Paul Yunusov [mailto:[EMAIL PROTECTED] Sent: 20 August 2003 13:24 To: Tomcat Users List Subject: Re: Installing Tomcat as a Service On August 20, 2003 04:19 am, Stuart Stephen wrote: Hi all, How might I go about installing Tomcat as a service in RedHat 9.0. I've never installed a service under linux manually before and I'm not sure what to do. I can't find the appropriate documentation in the manuals for either Tomcat or RedHat. I must be looking in the wrong places :O( UNRELATED: Also, If I wanted to install a java program as a service, how might I do this? Is this a similar process? Regards, Stuart man chkconfig man serviceconf man init For a Java program, write a wrapper shell script like Tomcat authors did with catalina.sh. Paul - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Installing Tomcat as a Service
Sounds like your problem can be easily solved by reading the manpage, as the previous email from Paul suggests. man chkconfig will tell you exactly why service service-name does not support chkconfig The whole point of chkconfig is to manage the installing of the service for you ( e.g. symlinks to init.d/yourscript from different run levels) You need specially formatted comments in your scripts, starting with something like # chkconfig : 2345 80 20 - the manpage has an example. -Original Message- From: Stuart Stephen [mailto:[EMAIL PROTECTED] Sent: Wednesday, August 20, 2003 10:57 AM To: Tomcat Users List Subject: RE: Installing Tomcat as a Service Thanks for the reply, I've tried creating a script in the /etc/init.d directory and then running the chkconfig --add script-name and this hasn't worked for me. I'm getting an error saying that: service service-name does not support chkconfig I must still be doing something wrong? The script has the same permissions showing in the ls -l list? -Original Message- From: Paul Yunusov [mailto:[EMAIL PROTECTED] Sent: 20 August 2003 13:24 To: Tomcat Users List Subject: Re: Installing Tomcat as a Service On August 20, 2003 04:19 am, Stuart Stephen wrote: Hi all, How might I go about installing Tomcat as a service in RedHat 9.0. I've never installed a service under linux manually before and I'm not sure what to do. I can't find the appropriate documentation in the manuals for either Tomcat or RedHat. I must be looking in the wrong places :O( UNRELATED: Also, If I wanted to install a java program as a service, how might I do this? Is this a similar process? Regards, Stuart man chkconfig man serviceconf man init For a Java program, write a wrapper shell script like Tomcat authors did with catalina.sh. Paul - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: CVS with tomcat
http://jakarta.apache.org/tomcat/tomcat-4.1-doc/manager-howto.html#Executing%20Manager%20Commands%20With%20Ant -Original Message- From: SuniX [mailto:[EMAIL PROTECTED] Sent: Wednesday, August 20, 2003 1:37 PM To: Tomcat Users List Subject: Re: CVS with tomcat Thank you Can you give an example of ant source whick reload and deploy to a tomcat server? It can help me. Thanks Paul Sundling wrote: I'm not sure why you'd want to have it deployed automatically. You can probably do it with ant and cruise control? With ant, you can create targets that reload your app or deploy it to a tomcat server. That's what I do currently and it even integrates well with eclipse! If you really want to do it automatically I heard cruise control does that sort of functionality, but I'm not sure about having it look for changes in CVS. SuniX wrote: Hi Is there a way to use CVS with tomcat ? i want my tomcat server to check a cvs project and deployed it automaticaly. (cvs server and tomcat server in the same machine running on a debian testing) - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: about web.xml and servlet mapping and reloading
I messed around with this quite a bit because of context-params that we kept updating in web.xml, but that didn't update when we did a reload. I read the documentation that said that stop restart of a web-app would reread the web.xml, however in our version 4.0.6 this was NOT the case. We have moved to tomat 4.1.24, and it now detects that the web.xml has been changed and rereads it ( exactly when it get's reread seems to be an un-exact science - but if you do a reload it happens straight away ), so it's not a problem anymore. Of course I don't know if the servlet container updates it's mappings in accordance with the now re-read web.xml Steph -Original Message- From: Mike Curwen [mailto:[EMAIL PROTECTED] Sent: Tuesday, August 19, 2003 9:48 AM To: 'Tomcat Users List' Subject: RE: about web.xml and servlet mapping and reloading As I read it, you are asked to stop and start the *web application* not Tomcat. So instead of a single 'reload' click, you must first click 'stop' and then 'start'. -Original Message- From: Nitschke Michael [mailto:[EMAIL PROTECTED] Sent: Tuesday, August 19, 2003 6:30 AM To: [EMAIL PROTECTED] Subject: about web.xml and servlet mapping and reloading I try to dynamically create and change servlet mapping in the web.xml in full production mode and then reload/reread the web.xml to update the mapping, but as i read in the manage application: quoteNOTE: The /WEB-INF/web.xml web application configuration file is not reread on a reload. If you have made changes to your web.xml file you must stop then start the web application. /quote it does not work like i need it, because the tomcat should not be restarted (loss of temporary data). Is there a way to keep the mappings available for tomcat and reloadable (no tomcat restart requiered). Thanx Mike - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: [OT] Some one executing windows commands in Tomcat 4.1.18.
this is just an IIS worm ( Nimda I think ) on someone else's server, sending requests to yours. You can see that all the requests are returning a 404. Almost everyone sees this at some stage. Don't worry about it. steph -Original Message- From: Antony paul [mailto:[EMAIL PROTECTED] Sent: Monday, August 11, 2003 8:11 AM To: tomcat mail list Subject: [OT] Some one executing windows commands in Tomcat 4.1.18. Hello, I have Tomcat standalone running on a local Intranet. The server is windows 2000 SP2. Today while checking the access log files I found the following lines xx.xx.xx.xx - - [11/Aug/2003:09:47:38 5050] GET /scripts/root.exe?/c+dir HTTP/1.0 404 716 xx.xx.xx.xx - - [11/Aug/2003:09:47:43 5050] GET /MSADC/root.exe?/c+dir HTTP/1.0 404 710 What does this mean ? Is there any vulnerability in Tomcat or this combination ?. I have uncommented the invoker servlet in web.xml. Is it creating the problem ?. regards Antony Paul - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Jasper2's JspC
There was a recent thread on doing this with Ant, search for subject Jasper, JSPC, Ant and Precompiling JSP's Otherwise, JspC will not create .class files for you, but the java files that JspC creates can just be compiled with javac, using Tomcat's classpath TOMCAT_HOME/common/lib/*.jar TOMCAT_HOME/shared/lib/*.jar as well as any web-app specific classpaths ( probably WEB-INF/lib/*.jar ) Steph -Original Message- From: Dmitry Beransky [mailto:[EMAIL PROTECTED] Sent: Wednesday, August 13, 2003 12:55 PM To: [EMAIL PROTECTED] Subject: Jasper2's JspC Hi, I'm having partial luck manually invoking JspC and compiling JSP pages on demand. I get as far as precomiling to .java, but for the world of me can't figure out how to get the java class compiled to bytecode. Looking at the source code for org.apache.jasper.compiler.Compiler, it appears that I should be getting a .class as well, but I'm not. Can anyone offer any pointers or sample source code I could look at (reminder, this is for Japser2)? Thanks Dmitry - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: ANT tasks for management console
Juraj Look for TOMCAT_HOME/server/lib/catalina-ant.jar and copy it to your ANT_HOME/lib directory. Then you need to define the targets, and add some tasks like this : !-- ** Tomcat / catalina.ant tasks ** -- taskdef name=deploy classname=org.apache.catalina.ant.DeployTask / taskdef name=undeploy classname=org.apache.catalina.ant.UndeployTask / taskdef name=list classname=org.apache.catalina.ant.ListTask / taskdef name=start classname=org.apache.catalina.ant.StartTask / taskdef name=stop classname=org.apache.catalina.ant.StopTask / taskdef name=reload classname=org.apache.catalina.ant.ReloadTask/ target name=reload !-- reload the web application in tomcat -- echo message=Reloading tomcat web app on port : ${tomcat.port} / reload url=${tomcat.manager} path=/${context-path} username=${tomcat.usr} password=${tomcat.pwd} / /target target name=war mkdir dir=${deploy}/ war warfile=${deploy}/${context-path}.war webxml=${dist}/web.xml fileset dir=${rootdir} exclude name=**/build.xml/ exclude name=**/web.xml/ exclude name=**/dev/**/ exclude name=**/temp/**/ exclude name=**/CVS/**/ exclude name=**/*.java/ /fileset /war /target target name=deploy description=Deploys a Web application deploy url=${tomcat.manager} username=${tomcat.usr} password=${tomcat.pwd} path=/${context-path} war=file:${war-path} / /target target name=undeploy description=Undeploys a Web application undeploy url=${tomcat.manager} username=${tomcat.usr} password=${tomcat.pwd} path=/${context-path} / /target target name=redeploy description=Undeploys and deploys a Web aplication antcall target=undeploy / antcall target=deploy / /target target name=list description=Lists Web applications echo message=Listing the applications/ list url=${tomcat.manager} username=${tomcat.usr} password=${tomcat.pwd} / /target target name=start description=Starts a Web application echo message=Starting the application/ start url=${tomcat.manager} username=${tomcat.usr} password=${tomcat.pwd} path=/${context-path} / /target target name=stop description=Stops a Web application echo message=Stopping the application/ stop url=${tomcat.manager} username=${tomcat.usr} password=${tomcat.pwd} path=/${context-path} / /target -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Thursday, July 31, 2003 3:38 AM To: [EMAIL PROTECTED] Subject: ANT tasks for management console Hi, Catalina 4.1.24 contains some ANT-tasks to call the management application to deploy, reload and delete apps. Where can I find these tasks to include them in my build? Juraj Mit freundlichen Grüssen Juraj Lenharcik T-Systems International GmbH Systems Integration 1 eFactory Solutions Business Unit Manufacturing Solutions Hausadresse: Fasanenweg 5, 70771 Leinfelden-Echterdingen phone:+49 (711) 972 46185 fax: +49 (711) 972 48109 mailto:[EMAIL PROTECTED] www.t-systems.com http://www.t-systems.com www.efactory-solutions.com http://www.efactory-solutions.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Jasper, JSPC, Ant and Precompiling JSP's
Mark, On compiling the _jsp.java files - yes I had to use foreach . And then because javac works recursively on whatever directory you point it at ( now that every file is in the same package ), I had to move the contents of each dir to a tempdir, compile the tempdir, move classfiles back. Full ( and long ) example below : Steph !-- Translate and compile all jsp files for current web app -- target name=jspc depends=tomcat-setworkdir,jspc_preparse foreach target=jspc_compile param=param.jspdir path dirset dir=${webapp.workdir} /dirset /path /foreach /target !-- Use Jasper2 to parse jsp into java -- target name=jspc_preparse description=Use Jasper2 to parse jsp into java mkdir dir=${webapp.workdir}/ jspc srcdir=${rootdir} destdir=${webapp.workdir} failonerror=false classpathref=jspc_parse.classpath package=org.apache.jsp compiler=jasper41 exclude name=**/WEB-INF/**/ exclude name=include/**/ /jspc !-- Fix all the package names -- replaceregexp match=^package org.apache.jsp.*; replace=package org.apache.jsp; fileset dir=${webapp.workdir} include name=**/*.java / /fileset /replaceregexp /target target name=jspc_compile description=Compiling _jsp.java files for one tomcat directory echo message=jspc_compile called for ${param.jspdir} / property name=tempbuild value=${rootdir}/WEB-INF/temp/src / mkdir dir=${tempbuild} / copy todir=${tempbuild} fileset dir=${param.jspdir} include name=*.java / /fileset /copy javac srcdir=${tempbuild} destdir=${tempbuild} optimize=off debug=on failonerror=true classpath path refid=build.classpath / pathelement location=${tomcat.home}/common/classes/ fileset dir=${tomcat.home}/common/lib include name=*.jar/ /fileset pathelement location=${tomcat.home}/shared/classes/ fileset dir=${tomcat.home}/shared/lib include name=*.jar/ /fileset /classpath /javac available property=package.created file=${tempbuild}/org/apache/jsp / !-- If no jsp / java files in this dir, then skip move because it would fail -- if istrue value=${package.created} / then move todir=${param.jspdir} fileset dir=${tempbuild}/org/apache/jsp / /move /then else echo message=No java files to compile in ${param.jspdir} / /else /if delete dir=${tempbuild} quiet=true/ /target -Original Message- From: Mark R. Diggory [mailto:[EMAIL PROTECTED] Sent: Tuesday, August 05, 2003 10:02 PM To: Tomcat Users List Subject: Re: Jasper, JSPC, Ant and Precompiling JSP's Ah, o.k. I had misunderstood what that attribute was for in the Ant Manual. I will try it and verify if the packaging comes out right. If I understand correctly, I will still need to walk the directories with the forEach task to get them compiled to classes, is this correct? thanks again for the help, -Mark Steph Richardson wrote: Mark, The jspc task that I used from the standard Optional Tasks that come with ant, does support a webapp parameter, and this works fine to compile the whole webapp without any regexp voodoo ( I didn't use it because it won't allow you to exclude any files ). I did see once a conversation on the ant-dev list that complained about how brittle the jspc task has been to maintain. So jasper ( with 4.1.28 ) comes with it's own built in task to completely compile a webapp. As described here : http://jakarta.apache.org/tomcat/tomcat-4.1-doc/jasper-howto.html#Web%20Application%20Compilation If you ignore the part about the web.xml fragment, and make sure your output dir is the same as your Tomcat workdir, then this works too ( I think - I did so many experiments my mind is now cloudy ). Steph
RE: Jasper, JSPC, Ant and Precompiling JSP's
Mark, The jspc task that I used from the standard Optional Tasks that come with ant, does support a webapp parameter, and this works fine to compile the whole webapp without any regexp voodoo ( I didn't use it because it won't allow you to exclude any files ). I did see once a conversation on the ant-dev list that complained about how brittle the jspc task has been to maintain. So jasper ( with 4.1.28 ) comes with it's own built in task to completely compile a webapp. As described here : http://jakarta.apache.org/tomcat/tomcat-4.1-doc/jasper-howto.html#Web%20Application%20Compilation If you ignore the part about the web.xml fragment, and make sure your output dir is the same as your Tomcat workdir, then this works too ( I think - I did so many experiments my mind is now cloudy ). Steph -Original Message- From: Mark R. Diggory [mailto:[EMAIL PROTECTED] Sent: Monday, August 04, 2003 5:05 PM To: Tomcat Users List Subject: Re: Jasper, JSPC, Ant and Precompiling JSP's Bingo! Thats pretty tight. I hadn't thought of using regexp, but I'll give this a try, it seems pretty logical. I didn't realize someone had contributed a forEach task. I'd still like to hear about if theres any work ongoing in relation to JspC and precompilation of entire webapplications in Tomcat? thanks again, Mark Steph Richardson wrote: Mark, I have a working solution for pre-compiling jsp, that I am using successfully with all our tomcat installations. The target looks like : target name=jspc_preparse description=Use Jasper2 to parse jsp into java mkdir dir=${webapp.workdir}/ jspc srcdir=${webapp.rootdir} destdir=${webapp.workdir} failonerror=false classpathref=jspc_parse.classpath package=org.apache.jsp compiler=jasper41 exclude name=**/WEB-INF/**/ exclude name=include/**/ /jspc !-- Fix all the package names -- replaceregexp match=^package org.apache.jsp.*; replace=package org.apache.jsp; fileset dir=${webapp.workdir} include name=**/*.java / /fileset /replaceregexp /target I then use foreach from antcontrib to iterate over the directories and compile them individually. Tomcat seems to accept all the resulting class files at runtime with no problems. Regards, Steph -Original Message- From: Steph Richardson [mailto:[EMAIL PROTECTED] Sent: Friday, August 01, 2003 7:06 PM To: Tomcat Users List Subject: RE: Jasper, JSPC, Ant and Precompiling JSP's That is EXACTLY what I am trying to do today. I've tooled around in the ant code, and it seems this is more of a jasper issue than an ant one, because ant passes a long list of files to jasper, with the unwanted pathnames that end up as part of your package name. I'm pretty sure if you used something like foreach to iterate through the same fileset that is being created in the jspc task, and called jspc for each directory individually, and used the package=org.apache.jsp attribute, then this would work - because then jasper wouldn't know about you're own subdirectory. But this seems ugly so I haven't actually done it yet. You can use the webapp element inside jspc, but then jasper doesn't know about your exclude and so tries to compile some fragment.jsp type include files, that are not really full jsp files, and so it crashes on those ( this is my current problem ). But if all your included files are called .inc rather than .jsp then this may work. jspc destdir=${webapp.workdir} failonerror=false classpathref=jspPreCompile.classpath package=org.apache.jsp compiler=jasper41 webapp basedir=${webapp.path}/ exclude name=**/WEB-INF/**/ exclude name=include/**/ /jspc So now I'm trying to make an ant step or task to replace the first line of every generated _jsp.java file with the correct package name, between generating them and compiling them. Plz met me know if you have something better. Regards, Steph PS - if you're from the same HMDC i know, I suspect the site you are trying to pre-compile, is one I wrote last summer. -Original Message- From: Mark R. Diggory [mailto:[EMAIL PROTECTED] Sent: Friday, August 01, 2003 5:19 PM To: Tomcat Users List Subject: Jasper, JSPC, Ant and Precompiling JSP's Hello, I've done my best to review the archives to resolve my problem, but I've not found a solution there so I'm posting it. I'm stuck back on Tomcat 4.1.24 (LE) and I'm encountering some issues with JSP Precompilation using Ant and JSPC. First let me outline my problem. Most messages I've read
RE: Jasper, JSPC, Ant and Precompiling JSP's
Mark, I have a working solution for pre-compiling jsp, that I am using successfully with all our tomcat installations. The target looks like : target name=jspc_preparse description=Use Jasper2 to parse jsp into java mkdir dir=${webapp.workdir}/ jspc srcdir=${webapp.rootdir} destdir=${webapp.workdir} failonerror=false classpathref=jspc_parse.classpath package=org.apache.jsp compiler=jasper41 exclude name=**/WEB-INF/**/ exclude name=include/**/ /jspc !-- Fix all the package names -- replaceregexp match=^package org.apache.jsp.*; replace=package org.apache.jsp; fileset dir=${webapp.workdir} include name=**/*.java / /fileset /replaceregexp /target I then use foreach from antcontrib to iterate over the directories and compile them individually. Tomcat seems to accept all the resulting class files at runtime with no problems. Regards, Steph -Original Message- From: Steph Richardson [mailto:[EMAIL PROTECTED] Sent: Friday, August 01, 2003 7:06 PM To: Tomcat Users List Subject: RE: Jasper, JSPC, Ant and Precompiling JSP's That is EXACTLY what I am trying to do today. I've tooled around in the ant code, and it seems this is more of a jasper issue than an ant one, because ant passes a long list of files to jasper, with the unwanted pathnames that end up as part of your package name. I'm pretty sure if you used something like foreach to iterate through the same fileset that is being created in the jspc task, and called jspc for each directory individually, and used the package=org.apache.jsp attribute, then this would work - because then jasper wouldn't know about you're own subdirectory. But this seems ugly so I haven't actually done it yet. You can use the webapp element inside jspc, but then jasper doesn't know about your exclude and so tries to compile some fragment.jsp type include files, that are not really full jsp files, and so it crashes on those ( this is my current problem ). But if all your included files are called .inc rather than .jsp then this may work. jspc destdir=${webapp.workdir} failonerror=false classpathref=jspPreCompile.classpath package=org.apache.jsp compiler=jasper41 webapp basedir=${webapp.path}/ exclude name=**/WEB-INF/**/ exclude name=include/**/ /jspc So now I'm trying to make an ant step or task to replace the first line of every generated _jsp.java file with the correct package name, between generating them and compiling them. Plz met me know if you have something better. Regards, Steph PS - if you're from the same HMDC i know, I suspect the site you are trying to pre-compile, is one I wrote last summer. -Original Message- From: Mark R. Diggory [mailto:[EMAIL PROTECTED] Sent: Friday, August 01, 2003 5:19 PM To: Tomcat Users List Subject: Jasper, JSPC, Ant and Precompiling JSP's Hello, I've done my best to review the archives to resolve my problem, but I've not found a solution there so I'm posting it. I'm stuck back on Tomcat 4.1.24 (LE) and I'm encountering some issues with JSP Precompilation using Ant and JSPC. First let me outline my problem. Most messages I've read to date focus on using JSP recompiling to turn the JSP into Servlets stored in a WAR file and require generating a fragment web.xml file and including it into your web.xml, I AM NOT trying to do this. I want my JSP's to get precompiled into the work directory of Tomcat and used from there, the exact same way that Tomcat does it. This way afterward, if the jsp is modified, tomcat can still recompile it. I have the following jspc and javac tasks coded in my build.xml: mkdir dir=/var/tomcat4/work/Standalone/localhost/Foo/ jspc srcdir=${deploy.home} destdir=/var/tomcat4/work/Standalone/localhost/Foo failonerror=false compiler=jasper41 classpath !-- snip -- /classpath exclude name=**/WEB-INF/**/ /jspc javac destdir=/var/tomcat4/work/Standalone/localhost/Foo optimize=off debug=on failonerror=false srcdir=/var/tomcat4/work/Standalone/localhost/Foo excludes=**/*.smap classpath !-- snip -- /classpath /javac Both tasks get completed successfully. I observe problems in the package names of the JSPC generated java files where the following is the case. /var/tomcat/webapps/Foo/Bar/Bam.jsp results in the package name package Bar; ... which becomes a problem when I try
RE: Jasper, JSPC, Ant and Precompiling JSP's
That is EXACTLY what I am trying to do today. I've tooled around in the ant code, and it seems this is more of a jasper issue than an ant one, because ant passes a long list of files to jasper, with the unwanted pathnames that end up as part of your package name. I'm pretty sure if you used something like foreach to iterate through the same fileset that is being created in the jspc task, and called jspc for each directory individually, and used the package=org.apache.jsp attribute, then this would work - because then jasper wouldn't know about you're own subdirectory. But this seems ugly so I haven't actually done it yet. You can use the webapp element inside jspc, but then jasper doesn't know about your exclude and so tries to compile some fragment.jsp type include files, that are not really full jsp files, and so it crashes on those ( this is my current problem ). But if all your included files are called .inc rather than .jsp then this may work. jspc destdir=${webapp.workdir} failonerror=false classpathref=jspPreCompile.classpath package=org.apache.jsp compiler=jasper41 webapp basedir=${webapp.path}/ exclude name=**/WEB-INF/**/ exclude name=include/**/ /jspc So now I'm trying to make an ant step or task to replace the first line of every generated _jsp.java file with the correct package name, between generating them and compiling them. Plz met me know if you have something better. Regards, Steph PS - if you're from the same HMDC i know, I suspect the site you are trying to pre-compile, is one I wrote last summer. -Original Message- From: Mark R. Diggory [mailto:[EMAIL PROTECTED] Sent: Friday, August 01, 2003 5:19 PM To: Tomcat Users List Subject: Jasper, JSPC, Ant and Precompiling JSP's Hello, I've done my best to review the archives to resolve my problem, but I've not found a solution there so I'm posting it. I'm stuck back on Tomcat 4.1.24 (LE) and I'm encountering some issues with JSP Precompilation using Ant and JSPC. First let me outline my problem. Most messages I've read to date focus on using JSP recompiling to turn the JSP into Servlets stored in a WAR file and require generating a fragment web.xml file and including it into your web.xml, I AM NOT trying to do this. I want my JSP's to get precompiled into the work directory of Tomcat and used from there, the exact same way that Tomcat does it. This way afterward, if the jsp is modified, tomcat can still recompile it. I have the following jspc and javac tasks coded in my build.xml: mkdir dir=/var/tomcat4/work/Standalone/localhost/Foo/ jspc srcdir=${deploy.home} destdir=/var/tomcat4/work/Standalone/localhost/Foo failonerror=false compiler=jasper41 classpath !-- snip -- /classpath exclude name=**/WEB-INF/**/ /jspc javac destdir=/var/tomcat4/work/Standalone/localhost/Foo optimize=off debug=on failonerror=false srcdir=/var/tomcat4/work/Standalone/localhost/Foo excludes=**/*.smap classpath !-- snip -- /classpath /javac Both tasks get completed successfully. I observe problems in the package names of the JSPC generated java files where the following is the case. /var/tomcat/webapps/Foo/Bar/Bam.jsp results in the package name package Bar; ... which becomes a problem when I try to access this JSP included into another, I get the following error java.lang.NoClassDefFoundError: org/apache/jsp/Bam_jsp (wrong name: Bar/Bam_jsp) at java.lang.ClassLoader.defineClass0(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:502) at java.lang.ClassLoader.defineClass(ClassLoader.java:431) at org.apache.jasper.servlet.JasperLoader.loadClass(Unknown Source) at org.apache.jasper.servlet.JasperLoader.loadClass(Unknown Source) at org.apache.jasper.JspCompilationContext.load(Unknown Source) at org.apache.jasper.servlet.JspServletWrapper.getServlet(Unknown Source) at org.apache.jasper.compiler.Compiler.isOutDated(Unknown Source) at org.apache.jasper.compiler.Compiler.isOutDated(Unknown Source) ... I read somewhere that work had been done on my version (4.1.24) to eliminate a naming conflict problem. I assume this is why there are now package names on my _jsp.java files. I find that when I let Tomcat/Jasper compile all my jsp's the java files *all* have the package name org.apache.jsp no matter what their directory. I assume that my compilation is conflicting with Tomcats because of the package naming differences. So, I've tried adding the following attribute package=org.apache.jsp to the jspc task, but this results in even more problems because all the package names now look like: package org.apache.jsp.Bar; and when they are compiled, they end up in a separate directory /var/tomcat4/work/Foo/org/apache/jsp/Bar/Bam_jsp.java
RE: ANT tasks for management console
Look for catalina-ant.jar - probably in $TOMCAT_HOME/server/lib. Copy it to your $ANT_HOME/lib. We use these in our build files - I included the XML fragments from our build files if they're useful ( obviously you need to define a bunch of props used in these examples ) : taskdef name=deploy classname=org.apache.catalina.ant.DeployTask / taskdef name=undeploy classname=org.apache.catalina.ant.UndeployTask / taskdef name=list classname=org.apache.catalina.ant.ListTask / taskdef name=start classname=org.apache.catalina.ant.StartTask / taskdef name=stop classname=org.apache.catalina.ant.StopTask / taskdef name=reload classname=org.apache.catalina.ant.ReloadTask/ !-- ** Tomcat tasks ** -- target name=reload !-- reload the web application in tomcat -- echo message=Reloading tomcat web app on port : ${tomcat.port} / reload url=${tomcat.manager} path=/${context-path} username=${tomcat.usr}password=${tomcat.pwd} / /target target name=deploy description=Deploys a Web application deploy url=${tomcat.manager} username=${tomcat.usr} password=${tomcat.pwd} path=/${context-path} war=file:${war-path} / /target target name=undeploy description=Undeploys a Web application undeploy url=${tomcat.manager} username=${tomcat.usr} password=${tomcat.pwd} path=/${context-path} / /target target name=redeploy description=Undeploys and deploys a Web aplication antcall target=undeploy / antcall target=deploy / /target target name=list description=Lists Web applications echo message=Listing the applications/ list url=${tomcat.manager} username=${tomcat.usr} password=${tomcat.pwd} / /target target name=start description=Starts a Web application echo message=Starting the application/ start url=${tomcat.manager} username=${tomcat.usr} password=${tomcat.pwd} path=/${context-path} / /target target name=stop description=Stops a Web application echo message=Stopping the application/ stop url=${tomcat.manager} username=${tomcat.usr} password=${tomcat.pwd} path=/${context-path} / /target -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Thursday, July 31, 2003 3:38 AM To: [EMAIL PROTECTED] Subject: ANT tasks for management console Hi, Catalina 4.1.24 contains some ANT-tasks to call the management application to deploy, reload and delete apps. Where can I find these tasks to include them in my build? Juraj Mit freundlichen Grüssen Juraj Lenharcik T-Systems International GmbH Systems Integration 1 eFactory Solutions Business Unit Manufacturing Solutions Hausadresse: Fasanenweg 5, 70771 Leinfelden-Echterdingen phone:+49 (711) 972 46185 fax: +49 (711) 972 48109 mailto:[EMAIL PROTECTED] www.t-systems.com http://www.t-systems.com www.efactory-solutions.com http://www.efactory-solutions.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Suggestions ?
I assume any html type tags that may be included in the text, you would want rendered as visible HTML tags in the browser. So use a HTML encoding method. There doesn't seem to be a JRE standard for this, so something like this will do it : public static String HTMLEncode( String unenc ) { final String[] tokens = new String[] {, , \, '}; final String[] replacement = new String[] {lt;, gt;, quot;, #39;}; StringBuffer sb = new StringBuffer(unenc); for(int i = 0; itokens.length; i++) { int idx = 0; while((idx = sb.indexOf(tokens[i], idx)) != -1) sb.replace(idx, idx + tokens[i].length(), replacement[i]); } return sb.toString(); } -Original Message- From: Mufaddal Khumri [mailto:[EMAIL PROTECTED] Sent: Thursday, July 31, 2003 4:51 AM To: Tomcat Users List Subject: Suggestions ? Hi, Am using tomcat 4.1.24. Have a XYZ.jsp with a form on it take data from the user. Once the user clicks submit the data is stored in the database and the data that the user entered is shown to him on ABC.jsp. The problem is that the user can enter anything in the text field and text area of the form on XYZ.jsp. For example in the description text area he or she might enter - text, an http url, maybe html tags etc. Now when i grab this data from the form and store it to the databse it works fine, but when i grab the data from the database and render it on ABC.jsp it gets messed up because the html tags in the data interfere with the html of the page. Is there a way in tomcat escape such characters or are there java methods that i could use to pass this string through that would do the escaping for me ? Thanks. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Can I include jsp files that are in a JAR / WAR ?
Hi, I am trying to include jsp fragments that are located in an archive file. I have an environment, where several web-apps share a set of common include files, that each web-app statically includes, with the %@ include file= % directive. For the development version of this environment, I would like to be able to deploy the shared include files as a single jar or war file, that is then referenced by the jsp pages in the web-app - so that the include files are included directly from the jar. This is for neatness, and to avoid the possible confusion that would come from having multiple copies of the shared includes ( one in each web-app ) hanging around the development environment. I had hoped something like : %@ include file=/WEB-INF/include/inc.jar/fragment.jsp % would work, but fo course it doesn't. Any suggestions ? Thanks in advance, Steph - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]