File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Tomcat and the fly likes Multilevel app structure Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Reply Bookmark "Multilevel app structure" Watch "Multilevel app structure" New topic
Author

Multilevel app structure

Jay Grant
Greenhorn

Joined: Feb 09, 2012
Posts: 7
Anyone ever tried to deploy (manually in this case, for simplicity) into the following type of structure:

/tomcat/webapps/APPBASE/APPSUBDIR/WEB-INF/...

as opposed to the documented approved structure of:

/tomcat/webapps/APPBASE/WEB-INF/...

i.e. I'm inserting the APPSUBDIR additional directory, and wish to invoke an associated servlet via:

http://localhost:8080/APPBASE/APPSUBDIR/servletname

The issue seems to revolve around specifications in the context.xml and web.xml (and maybe other) files. I've attempted numerous combinations for path, docBase, servlet-mapping, etc. but without success. I haven't encountered any examples of what I'm attempting above, so perhaps it's illegitimate.

Grateful for any responses. Thanks.

Bear Bibeault
Author and opinionated walrus
Marshal

Joined: Jan 10, 2002
Posts: 50693

The Servlet Specification makes no provisions for nested web applications. What are you actually trying to accomplish?

[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 13842

It's certainly possible to set up a servlet mapping which maps "/APPSUBDIR/servlet" to a servlet in your web application, I do that regularly. (The web application which I'm working on is basically a home for a collection of smaller applications, which sounds a lot like your situation.)
Jay Grant
Greenhorn

Joined: Feb 09, 2012
Posts: 7
Thanks guys. So Paul, does your structure look like "/APPBASE/APPSUBDIR/servlet"?
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 13842

I'm not sure what you mean by "structure". My URL for a servlet in my application generally looks like http://hostname/MyApp/SomeSubApp/servletname.
Bear Bibeault
Author and opinionated walrus
Marshal

Joined: Jan 10, 2002
Posts: 50693

There's a big difference between where a servlet is mapped to, and where the servlet class resides. You are not at all being clear regarding what you are trying to do. So I ask again, what are you actually trying to accomplish?
Jay Grant
Greenhorn

Joined: Feb 09, 2012
Posts: 7
Bear, my servlet is currently qualified only by application (base) name, i.e. /APPBASE/servlet. I simply want to further qualify it by vendor name, i.e. /VENDORNAME/APPBASE/servlet. Your URL format, Paul, reflects what I'm attempting. I presume that your associated directory structure (which is what I mean by "structure") is of the form (correct me if not):

/tomcat/webapps//MyApp/SomeSubApp/WEB-INF/...

What are your associated xml (context.xml, web.xml, etc.) entries for that application? Thanks.
Bear Bibeault
Author and opinionated walrus
Marshal

Joined: Jan 10, 2002
Posts: 50693

You don't need any folders to do that. And you certainly don't need nested/multi-level web apps. Simply specify the mapping that you want in the deployment descriptor.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 13842

Jay Grant wrote:Your URL format, Paul, reflects what I'm attempting. I presume that your associated directory structure (which is what I mean by "structure") is of the form (correct me if not):

/tomcat/webapps//MyApp/SomeSubApp/WEB-INF/...


No, it isn't. If I were using Tomcat (I'm not, but it's Java EE so the rules are the same) then my application's directory would be

/tomcat/webapps/MyApp

And under that I have the WEB-INF directory for MyApp, which as you know is where /classes and /lib are placed to hold servlets and associated resources like jars. This is the normal way to set up a web application.

Sometimes my sub-apps need to refer to things like Javascript and CSS files which are specific to the sub-app. In this case I have a /SubApp directory under the /MyApp directory where those things are stored. The URL for those things then looks like http://server/MyApp/SubApp/actions.js and so on.

Each of the sub-apps has a collection of JSPs where are stored in a directory called /SubApp under the /WEB-INF directory. This means that after a servlet does its work it will forward to a JSP at "/WEB-INF/SubApp/Whatever.jsp". And I believe we already discussed how to set up servlet mappings to give the illusion that directories exist on the server for each sub-app.
Jay Grant
Greenhorn

Joined: Feb 09, 2012
Posts: 7
OK; thanks guys.
 
 
subject: Multilevel app structure
 
Threads others viewed
missing application web.xml using defaults
Help with Struts
Map URI to worker - Tomcat
Getting Tomcat to recognize directory
How to do Deployment ?
developer file tools