tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Blaxton <blaxx...@yahoo.com>
Subject Re: MVC or Model2 with Tomcat
Date Mon, 05 Dec 2011 06:24:49 GMT




________________________________
 From: André Warnier <aw@ice-sa.com>
To: Tomcat Users List <users@tomcat.apache.org> 
Sent: Monday, December 5, 2011 4:13:33 AM
Subject: Re: MVC or Model2 with Tomcat
 
Blaxton wrote:
> 
> 
> 
> ________________________________
>  From: André Warnier <aw@ice-sa.com>
> To: Tomcat Users List <users@tomcat.apache.org> 
> Sent: Monday, December 5, 2011 2:00:09 AM
> Subject: Re: MVC or Model2 with Tomcat
>  
> Blaxton wrote:
>>
>>
>> ________________________________
>>   From: Pid * <pid@pidster.com>
>> To: Tomcat Users List <users@tomcat.apache.org> 
>> Sent: Sunday, December 4, 2011 11:10:08 PM
>> Subject: Re: MVC or Model2 with Tomcat
>>  
>> On 4 Dec 2011, at 16:17, Blaxton <blaxxton@yahoo.com> wrote:
>>
>>>
>>>
>>> ________________________________
>>> From: André Warnier <aw@ice-sa.com>
>>> To: Tomcat Users List <users@tomcat.apache.org>
>>> Sent: Sunday, December 4, 2011 6:51:58 PM
>>> Subject: Re: MVC or Model2 with Tomcat
>>>
>>> Blaxton wrote:
>>>> I have created ROOT directory and placed index.jsp in ROOT directory
>>>> the same as your example:
>>>> /path/to/appbase/ROOT/index.jsp    -> myhost.com/index.jsp
>>>>
>>>> but that didn't work.
>>>>
>>>> I followed following instructions but those didn't work either.
>>>>
>>>> http://www.jguru.com/faq/view.jsp?EID=91006
>>>>
>>>> http://wiki.apache.org/tomcat/HowTo#How_do_I_make_my_web_application_be_the_Tomcat_default_application.3F
>>>>
>>>> is there any thing else I should do to work this out?
>>>>
>>> I wrote that second faq, but I don't see what it has to do with your problem.
>>>
>>> You haven't answered Pid's question :
>>>
>>>> Why do you need to do that to implement MVC?
>>> Nor his second question :
>>>
>>>> Without more information about your config, e.g. workers.properties it's
>>>> impossible to tell why this didn't work.
>>> And please, do not top-post.  It is very hard to follow a discussion when you
have to jump up and down in the mesage to understand what each phrase relates to.
>>>
>>> Also, thank you for providing the versions of Apache httpd and Tomcat up-front.
>>> But "mod_jk version 2", that does not exist.
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>>> For additional commands, e-mail: users-help@tomcat.apache.org
>>>
>>>
>>> My bad, the subject should have been "serving .jsp files from apache document
root"
>>> I just want to access my website as follow:
>>> www.mydomain.com/index.jsp
>>>
>>> the same as the solustion you wrote, but that solustion didn't work for me.
>>> maybe because in that solution you were talking about
>>> CATALINA_BASE/webapps/ROOT directory
>>> and I created CATALINA_BASE/webapps/myapplication/ROOT directory.
>>>
>>> can we have ROOT directory for each application ?
>>> like:
>>>
>>> CATALINA_BASE/webapps/ROOT
>>> CATALINA_BASE/webapps/firstapp/ROOT
>>> CATALINA_BASE/webapps/secondapp/ROOT
>> No, you can't. None of the docs day you can.
>>
>> ROOT is the special name for the default application, which serves
>> resources from / and handles all requests which are not handled by
>> other applications.
>>
>> Putting ROOT inside other apps just results in publishing that whole
>> dir as /appname/ROOT.
>>
>> If you don't provide other details of your config, no-one here will be
>> able to help, without a really, really lucky guess.
>>
>>
>> p
>>
>>
>>> anyway, here is the out put of the package query on my FreeBSD box:
>>> ap22-mo_jk-ap2-1.2.30_1 Apache2 JK module for connecting to Tomcat using AJP1X
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
>>
>>
>> Its a virtual host with following lines have been added to main httpd.conf:
>> LoadModule jk_module          libexec/apache22/mod_jk.so
>> JkWorkersFile /usr/local/etc/apache22/workers.properties
>> JkShmFile     /var/log/mod_jk.shm
>> JkLogFile     /var/log/mod_jk.log
>> JkLogLevel   debug 
>> JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
>>
>> and following JkMount directives for each virtual host:
>> JkMount  /appexmp1/*     appexmp1
>> JkMount  /appexmp1/*.jsp appexmp1
>>
>> and following is the worker file for two of the sites:
>> worker.list=appexmp2,appexmp1
>> worker.appexmp2.type=ajp13
>> worker.appexmp2.host=localhost
>> worker.appexmp2.port=8009
>> worker.appexmp1.type=ajp13
>> worker.appexmp1.host=localhost
>> worker.appexmp1.port=8109
>>
>>
>> Created separate directories in CATALINA_BASE/webapps/
>> for each application so , it contain following directories:
>> CATALINA_BASE/webapps/ROOT
>> CATALINA_BASE/webapps/appexmp1
>> CATALINA_BASE/webapps/appexmp2
>>
>> context file for each application resides in 
>> CATALINA_BASE/conf/Catalina/localhost for example:
>> CATALINA_BASE/conf/Catalina/localhost/appexmp1.xml
>> CATALINA_BASE/conf/Catalina/localhost/appexmp2.xml
>>
>> cat  CATALINA_BASE/conf/Catalina/localhost/appexmp1.xml
>> <Context path="/appexmp1" docBase="appexmp1" debug="0" reloadable="true" crossContext="true">
>> </Context>
>>
>> and web.xml file as follow:
>> cat CATALINA_BASE/webapps/appexmp1/WEB-INF/web.xml
>> <web-app xmlns="http://java.sun.com/xml/ns/javaee" version="2.5">
>> <servlet>
>>      <servlet-name>App1</servlet-name>
>>      <servlet-class>com.appexmp1.App1</servlet-class>
>>    </servlet>
>>
>>    <servlet-mapping>
>>      <servlet-name>App1</servlet-name>
>>      <url-pattern>/APP1</url-pattern>
>>    </servlet-mapping>
>>
>>    <welcome-file-list>
>>      <welcome-file>index.jsp</welcome-file>
>>    </welcome-file-list>
>>
>> </web-app>
>>
>>
>> I already can access mydomain.com/App1/index.jsp and every thing works fine
>> but want to be able to serve .jsp files as follow:
>> mydomain.com/index.jsp
>> for each of my virtual hosts.
>>
>> I hope I have provided enough information.
>>
> No. :-)
> 
> What we are still missing, is how you have defined the DocumentRoot in each of your Apache

> httpd VirtualHost's. And also any Alias directive which mentions "App1".
> 
> Because with your above setup, calling "mydomain.com/App1/index.jsp" can only work, if
you 
> have allowed Apache httpd to access your Tomcat applications directory directly.  Which

> you should not do.
> 
> Here is a reason why you should not do this :
> Try the following URL :
> mydomain.com/App1/WEB-INF/web.xml
> What do you see ?
> Do you want users to see that ?
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
> Sorry, based on context file the URL that I should have mentioned is 
> mydomain.com/appexmp1/index.jsp and not mydomain.com/App1/index.jsp
> 
> App1 is a servlet that just print some helloworld and that works fine.
> probably should have not mentioned that as it has nothing to do with jsp.
> 
> Apache DocumentRoot is not overlapping Tomcat's docbase.
> I already have provided context file and here is the apache DocumentRoot:
> DocumentRoot "/var/www/appexmp1/httpdocs"
> 
> accessing mydomain.com/appexmp1/WEB-INF/web.xml results file not exist.
> 
> mydomain.com/appexmp1/index.jsp  works fine but want to access mydomain.com/index.jsp

If you only want that index page there, then just move it under /ROOT/.

But if you want the whole of "appexmp1" to be called without the /appexmp1/ prefix, then :

In Tomcat itself, it is not complicated, just follow the earlier-mentioned FAQ.
(from memory: make a backup of /ROOT/*; delete what is under /ROOT/; move what is in 
/appexmp1/* to /ROOT/*; delete /appexmp1; modify your Context files accordingly; restart 
Tomcat).

BUT, you are going to have a harder time making the JkMount's work under Apache httpd.
Because now, you would have to replace this :
>> JkMount  /appexmp1/*     appexmp1
by this :
>> JkMount  /*     appexmp1

That's fine if you still want /appexmp2/* to be forwarded to the other application.
But if you also want the other application on the other tomcat to be ROOT on that tomcat,

you have a problem, because of course you cannot have
>> JkMount  /*     appexmp1
>> JkMount  /*     appexmp2

Think about it.  Maybe a better way would be to have a /index.html under Apache, with 
links to /appexmp1 and /appexmp2 ?

Also by the way, another little error in your previous setup :
In this :
>> JkMount  /appexmp1/*     appexmp1
>> JkMount  /appexmp1/*.jsp appexmp1
In the first line, you are already forwarding /appexmp1/* anyway, so the second line is 
useless.


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

One of the reasons I have installed stand alone Apache along with Tomcat
 is 
maybe in future use a load balancing feature and load balance several 
Tomcats.
do you think linking /index.html to /appexmp1 would make problem in tomcat ?

By linking /index.html  to /appexmp1, do you mean forwarding by placing
following metadata in index.html file:
<meta http-equiv="Refresh" 
content="5;url=mydomain.com/appexmp1/index.jsp" />

or there are other ways of linking index.html to mydomain.com/appexmp1/index.jsp ?
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message