RE: servlet access to static resources (pictures)
From: Patrick Flaherty [mailto:pflah...@rampageinc.com] Subject: Re: servlet access to static resources (pictures) Can I remove the context from the www.ft.com host altogether ? (It's Context and Host - be precise; case matters, even on Windows.) The Context element should never have been in server.xml. I don't need context for this host. Yes, you do, since there are Resource and numerous Environment elements included in it. The Context element should be placed in C:\all-my-apps\ROOT\META-INF\context.xml or in conf\Catalina\www.ft.com\ROOT.xml. The contents of the file should be: Context reloadable=true Resource name=jdbc/rampage auth=Container type=javax.sql.DataSource description=database maxActive=100 maxIdle=5 maxWait=15000 username=dbuser password=!Flyover driverClassName=com.mysql.jdbc.Driver url=jdbc:mysql://192.168.2.13:3306/ft driverName=jdbc:mysql://192.168.2.13:3306/ft/ Environment name=company.id value=0 type=java.lang.Long override=false/ Environment name=site.id value=0 type=java.lang.Integer override=false/ Environment name=timeout.interval value=3600 type=java.lang.Integer override=false/ Environment name=service.jobs value=com.rampageinc.services.JobService type=java.lang.String override=false/ Environment name=service.useraccesscontrol value=com.rampageinc.services.UserAccessControlService type=java.lang.String override=false/ Environment name=service.cms value=com.rampageinc.services.CMSService type=java.lang.String override=false/ Environment name=root.upload value=C:\TempUpload type=java.lang.String override=false/ Environment name=root.job value=\\Winserve-2008\Pat-10-3\Jobs type=java.lang.String override=false/ Environment name=root.db value=\\Winserve-2008\Pat-10-3\DB type=java.lang.String override=false/ Environment name=root.preps value=\\win2k3-xeon\pat-10-3\Preps type=java.lang.String override=false/ /Context Note that unused junk (such as Logger and debug) have been removed, along with the illegal path and docBase attributes. - Chuck THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: servlet access to static resources (pictures)
That make sense. Thank you. -P On Jan 14, 2010, at 10:20 AM, Caldarale, Charles R wrote: From: Patrick Flaherty [mailto:pflah...@rampageinc.com] Subject: Re: servlet access to static resources (pictures) Can I remove the context from the www.ft.com host altogether ? (It's Context and Host - be precise; case matters, even on Windows.) The Context element should never have been in server.xml. I don't need context for this host. Yes, you do, since there are Resource and numerous Environment elements included in it. The Context element should be placed in C:\all-my-apps\ROOT\META-INF\context.xml or in conf\Catalina \www.ft.com\ROOT.xml. The contents of the file should be: Context reloadable=true Resource name=jdbc/rampage auth=Container type=javax.sql.DataSource description=database maxActive=100 maxIdle=5 maxWait=15000 username=dbuser password=!Flyover driverClassName=com.mysql.jdbc.Driver url=jdbc:mysql:// 192.168.2.13:3306/ft driverName=jdbc:mysql://192.168.2.13:3306/ft/ Environment name=company.id value=0 type=java.lang.Long override=false/ Environment name=site.id value=0 type=java.lang.Integer override=false/ Environment name=timeout.interval value=3600 type=java.lang.Integer override=false/ Environment name=service.jobs value=com.rampageinc.services.JobService type=java.lang.String override=false/ Environment name=service.useraccesscontrol value=com.rampageinc.services.UserAccessControlService type=java.lang.String override=false/ Environment name=service.cms value=com.rampageinc.services.CMSService type=java.lang.String override=false/ Environment name=root.upload value=C:\TempUpload type=java.lang.String override=false/ Environment name=root.job value=\\Winserve-2008\Pat-10-3 \Jobs type=java.lang.String override=false/ Environment name=root.db value=\\Winserve-2008\Pat-10-3\DB type=java.lang.String override=false/ Environment name=root.preps value=\\win2k3-xeon\pat-10-3 \Preps type=java.lang.String override=false/ /Context Note that unused junk (such as Logger and debug) have been removed, along with the illegal path and docBase attributes. - Chuck THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
servlet access to static resources (pictures)
We have defined some paths to static resources in the server.xml: Context docBase=c:\pictureroot\applpictures path=/shop/applpictures reloadable=false/ Context docBase=c:\pictureroot\drawings path=/shop/drawings reloadable=false/ ... Context docBase=c:\pictureroot\prodpictures path=/shop/prodpictures reloadable=false/ Is there a way to get the absolute paths of these folders in a servlet? - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: servlet access to static resources (pictures)
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Holger, On 1/13/2010 9:52 AM, Holger Rieß wrote: We have defined some paths to static resources in the server.xml: Context docBase=c:\pictureroot\applpictures path=/shop/applpictures reloadable=false/ Context docBase=c:\pictureroot\drawings path=/shop/drawings reloadable=false/ ... Context docBase=c:\pictureroot\prodpictures path=/shop/prodpictures reloadable=false/ Where did you define these Context elements? Is there a way to get the absolute paths of these folders in a servlet? Typically, one uses the request.getRealPath() method to find context-relative paths on a filesystem. Unfortunately, no app server required to provide a readable filesystem to a webapp, so use of getRealPath is discouraged. Instead, try looking at the request.getResource family of methods: these can be used to read files out of WAR resources and other non-filesystem-based data stores. If you just want to serve static resources, why not use the DefaultServlet, which already knows how to serve them? - -chris -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.10 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAktN5IIACgkQ9CaO5/Lv0PB0JQCZAcTmtlHb82zxWJEcGWo5a8C0 VLEAnivM6TDeBbtnZPxwXU7xLtvcTfYT =nTyW -END PGP SIGNATURE- - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
RE: servlet access to static resources (pictures)
From: Christopher Schultz [mailto:ch...@christopherschultz.net] Subject: Re: servlet access to static resources (pictures) We have defined some paths to static resources in the server.xml: Where did you define these Context elements? Looks like the OP was pretty specific about where... Is there a way to get the absolute paths of these folders in a servlet? Typically, one uses the request.getRealPath() method to find context-relative paths on a filesystem. However, these are static-content only webapps, there are no servlets in that context that can do a request.getRealPath(), which, as you noted, is a bad idea anyhow. Instead, try looking at the request.getResource family of methods: Again, these are static-only webapps, so there are no servlets or JSPs around to handle requests, other than Tomcat's DefaultServlet. If you just want to serve static resources, why not use the DefaultServlet, which already knows how to serve them? Clearly, the OP is already doing that. I suspect the actual problem is that there are other, real webapps that want to manipulate the static resources. Best I can think of is environment variables or Java system properties to allow specification of the locations on a JVM-wide basis. - 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.
RE: servlet access to static resources (pictures)
The context elements are defined in /%CATALINA_HOME%/conf/server.xml: Server ... Service ... Engine ... Host ... Context docBase= ... Context docBase= ... ... /Host /Engine /Service /Server There are two web applications that have access to these resources. The servlets main task is to calculate picture dimensions with java.awt.Toolkit. The request.getResource methods don't find these 'extern' paths. Holger - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: servlet access to static resources (pictures)
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Holger, On 1/13/2010 11:23 AM, Holger Rieß wrote: The context elements are defined in /%CATALINA_HOME%/conf/server.xml: Server ... Service ... Engine ... Host ... Context docBase= ... Context docBase= ... ... /Host /Engine /Service /Server There are two web applications that have access to these resources. The servlets main task is to calculate picture dimensions with java.awt.Toolkit. The request.getResource methods don't find these 'extern' paths. So, you have one context with nothing but static content and another context with the servlets? Why not merge the two so there's no confusion? Aside from your original question: I'm not exactly sure what your requirements are, but it may be easier to use a simpler mechanism to determine picture dimensions than using java.awt.Toolkit to fully-load an image. Most image formats contain headers which indicate the dimensions of the image, while reading the full image data may require very heavy algorithms (I'm looking at you, discrete cosine transform). - -chris -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.10 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAktN+ukACgkQ9CaO5/Lv0PBwbACgnE0BwRmXRG9NacWtsdx+//dq Y8oAn0TeYUAOANhuKj1fe3c8TjrXPRW4 =u5tr -END PGP SIGNATURE- - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: servlet access to static resources (pictures)
Generally speaking, should your docBase point to the location containing your application ? For example Host : www.myapp.com appBase: c:\all-my-apps Application: app1 Location: c:\all-my-apps\app1 Generally speaking would point my docBase to c:\all-my-apps\app1? Thanks -P On Jan 13, 2010, at 11:23 AM, Holger Rieß wrote: The context elements are defined in /%CATALINA_HOME%/conf/server.xml: Server ... Service ... Engine ... Host ... Context docBase= ... Context docBase= ... ... /Host /Engine /Service /Server There are two web applications that have access to these resources. The servlets main task is to calculate picture dimensions with java.awt.Toolkit. The request.getResource methods don't find these 'extern' paths. Holger - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
RE: servlet access to static resources (pictures)
From: Patrick Flaherty [mailto:pflah...@rampageinc.com] Subject: Re: servlet access to static resources (pictures) Generally speaking, should your docBase point to the location containing your application ? Yes, but these aren't real applications - they're simply sets of static resources handled by the DefaultServlet. The configuration the OP has is fine, other than keeping Context elements in server.xml, which I wouldn't do. - Chuck THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: servlet access to static resources (pictures)
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Patrick, Aside from Chuck's comments... On 1/13/2010 12:01 PM, Patrick Flaherty wrote: Generally speaking, should your docBase point to the location containing your application ? For example Host : www.myapp.com appBase: c:\all-my-apps Application: app1 Location: c:\all-my-apps\app1 If your Host for www.myapp.com has autoDeploy=true, then explicitly creating a Context with docBase=[appBase]/something is likely to create confusion because Tomcat may try to deploy the same webapp twice on the same path. :( If autoDeploy=true, then having a webapp in c:\all-my-apps\app1.war or the directory c:\all-my-apps\app1 means that it will be automatically deployed and therefore no Context element need appear in conf/server.xml. Generally speaking would point my docBase to c:\all-my-apps\app1? Conceptually, yes. In practice, you should try to avoid explicitly setting the docBase unless you are using conf-file-based deployment using a deployment file in conf/[EngineName]/[HostName]/[AppName].xml. - -chris -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.10 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAktOMvkACgkQ9CaO5/Lv0PAl4wCdGn7y93C40qPUjCn2fmVKiaHU eHgAn2P4tC94CdKVuZAnsrdu98JSPc0D =lfnl -END PGP SIGNATURE- - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: servlet access to static resources (pictures)
On Jan 13, 2010, at 3:54 PM, Christopher Schultz wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Patrick, Aside from Chuck's comments... On 1/13/2010 12:01 PM, Patrick Flaherty wrote: Generally speaking, should your docBase point to the location containing your application ? For example Host : www.myapp.com appBase: c:\all-my-apps Application: app1 Location: c:\all-my-apps\app1 If your Host for www.myapp.com has autoDeploy=true, then explicitly creating a Context with docBase=[appBase]/something is likely to create confusion because Tomcat may try to deploy the same webapp twice on the same path. :( If autoDeploy=true, then having a webapp in c:\all-my-apps \app1.war or the directory c:\all-my-apps\app1 means that it will be automatically deployed and therefore no Context element need appear in conf/ server.xml. Generally speaking would point my docBase to c:\all-my-apps\app1? Conceptually, yes. In practice, you should try to avoid explicitly setting the docBase unless you are using conf-file-based deployment using a deployment file in conf/[EngineName]/[HostName]/[AppName].xml. So Chris, Based on my setup as described above which is not a war file but a directory that we just plunk down into appBase, should I remove the docBase parameter altogether (is that safe) or should it be there set as docBase= (empty) which is what I have seen in my readings about Context. One other item in my Context is path and it is set to path= (is that safe). If this is the only app for this host should it be set to path=/ (root) ? Thanks -P - -chris -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.10 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAktOMvkACgkQ9CaO5/Lv0PAl4wCdGn7y93C40qPUjCn2fmVKiaHU eHgAn2P4tC94CdKVuZAnsrdu98JSPc0D =lfnl -END PGP SIGNATURE- - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
RE: servlet access to static resources (pictures)
From: Patrick Flaherty [mailto:pflah...@rampageinc.com] Subject: Re: servlet access to static resources (pictures) Based on my setup as described above which is not a war file but a directory that we just plunk down into appBase, should I remove the docBase parameter altogether (is that safe) or should it be there set as docBase= (empty) which is what I have seen in my readings about Context. The docBase attribute must *never* be set to an empty string - doing so creates all sorts of havoc. It can be omitted in almost all cases except when the webapp is located outside of the Host appBase directory. One other item in my Context is path and it is set to path= (is that safe). The proper way to do this is remove the Context elements from server.xml. If you only have one webapp, name its directory (or .war file) ROOT (case-sensitive), under the Host appBase directory. The Context element, if needed, should be placed in [appBase]/ROOT/META-INF/context.xml, and must not contain path or docBase attributes. If there's nothing left in the Context element, you don't need it at all. If this is the only app for this host should it be set to path=/ (root) ? No, / is not the default webapp; is. But you shouldn't ever be setting path, anyway. - Chuck THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: servlet access to static resources (pictures)
documentation) -- !-- Cluster className=org.apache.catalina.ha.tcp.SimpleTcpCluster/ -- !-- The request dumper valve dumps useful debugging information about the request and response data received and sent by Tomcat. Documentation at: /docs/config/valve.html -- !-- Valve className=org.apache.catalina.valves.RequestDumperValve/ -- !-- This Realm uses the UserDatabase configured in the global JNDI resources under the key UserDatabase. Any edits that are performed against this UserDatabase are immediately available for use by the Realm. -- Realm className=org.apache.catalina.realm.UserDatabaseRealm resourceName=UserDatabase/ !-- Define the default virtual host Note: XML Schema validation will not work with Xerces 2.2. -- Host name=localhost appBase=webapps unpackWARs=true autoDeploy=true xmlValidation=false xmlNamespaceAware=false !-- SingleSignOn valve, share authentication between web applications Documentation at: /docs/config/valve.html -- !-- Valve className=org.apache.catalina.authenticator.SingleSignOn / -- !-- Access log processes all example. Documentation at: /docs/config/valve.html -- !-- Valve className=org.apache.catalina.valves.AccessLogValve directory=logs prefix=localhost_access_log. suffix=.txt pattern=common resolveHosts=false/ -- /Host Host name=www.ft.com appBase=c:/all-my-apps debug=0 unpackWARs=false autoDeploy=true Alias192.168.2.13/Alias Context path= docBase=c:/all-my-apps/ROOT debug=0 reloadable=true Logger className=org.apache.catalina.logger.FileLogger prefix=inhouse. suffix=.log timestamp=true/ Resource name=jdbc/rampage auth=Container type=javax.sql.DataSource description=database maxActive=100 maxIdle=5 maxWait=15000 username=dbuser password=!Flyover driverClassName=com.mysql.jdbc.Driver url=jdbc:mysql://192.168.2.13:3306/ft driverName=jdbc:mysql://192.168.2.13:3306/ft/ Environment name=company.id value=0 type=java.lang.Long override=false/ Environment name=site.id value=0 type=java.lang.Integer override=false/ Environment name=timeout.interval value=3600 type=java.lang.Integer override=false/ Environment name=service.jobs value=com.rampageinc.services.JobService type=java.lang.String override=false/ Environment name=service.useraccesscontrol value=com.rampageinc.services.UserAccessControlService type=java.lang.String override=false/ Environment name=service.cms value=com.rampageinc.services.CMSService type=java.lang.String override=false/ Environment name=root.upload value=C:\TempUpload type=java.lang.String override=false/ Environment name=root.job value=\\Winserve-2008\Pat-10-3\Jobs type=java.lang.String override=false/ Environment name=root.db value=\\Winserve-2008\Pat-10-3\DB type=java.lang.String override=false/ Environment name=root.preps value=\\win2k3-xeon\pat-10-3\Preps type=java.lang.String override=false/ /Context /Host /Engine /Service /Server On Jan 13, 2010, at 6:04 PM, Caldarale, Charles R wrote: From: Patrick Flaherty [mailto:pflah...@rampageinc.com] Subject: Re: servlet access to static resources (pictures) Based on my setup as described above which is not a war file but a directory that we just plunk down into appBase, should I remove the docBase parameter altogether (is that safe) or should it be there set as docBase= (empty) which is what I have seen in my readings about Context. The docBase attribute must *never* be set to an empty string - doing so creates all sorts of havoc. It can be omitted in almost all cases except when the webapp is located outside of the Host appBase directory. One other item in my Context is path and it is set to path= (is that safe). The proper way to do this is remove the Context elements from server.xml. If you only have one webapp, name its directory (or .war file) ROOT (case-sensitive), under the Host appBase directory. The Context element, if needed, should be placed in [appBase]/ROOT/META-INF/context.xml, and must not contain path or docBase attributes. If there's nothing left in the Context element, you don't need it at all. If this is the only app for this host should it be set to path=/ (root) ? No, / is not the default webapp; is. But you shouldn't ever be setting path, anyway. - 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