tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jagadish Gopi <JG...@atlassoft.com>
Subject FW: Error when reading a servlet
Date Mon, 20 Aug 2001 13:59:26 GMT

HI Richard,

Thanx a lot for replying back. 

I have followed all your advices but still am facing the same problem.

I have given something like this within my server.xml file
<Context path="/health"
docBase="/jakarta-tomcat-3.2.1/webapps/com/health/wls/servlets"
crossContext="true" debug="0" reloadable="true"></Context>

-> here the main reason why i have given docBase="/jaka......" is coz if I
give in as docBase="/webapps/com...." I get a error something like this 
"java.security.AccessControlException: access denied (java.io.FilePermission
C:\webapps\com\health\wls\servlets read) "
at
java.security.AccessControlContext.checkPermission(AccessControlContext.java
, Compiled Code)
at java.security.AccessController.checkPermission(AccessController.java,
Compiled Code)
at ...
 What I want you to note is it's looking for files within c:/webapps... but
actually I have dir structure as c:/jakara-tomcat-3.2.1/webapps.... 

One more doubt I had , you had written asking me to give within server.xml
file, something like this
<Context path="/health" docBase="webapps/health" etc...></Context>  

->Please tell me if I give in docbase as "webapps/health" how will it know
the exact servlets path... which is within webapps/com/health/wls/servlets

->And within my web.xml file which is within dir c:/jakarata-3.2.1/conf I
have created a servlet tags like 
<servlet>
        <servlet-name>
            HealthLogin 
        </servlet-name>
        <servlet-class>
            HealthLogin
        </servlet-class>
        <init-param>
            <param-name>Location</param-name>
            <param-value>c:/weblogic/health_resources/text.txt</param-value>
        </init-param>
    </servlet>
    <servlet-mapping>
        <servlet-name>
            HealthLogin
        </servlet-name>
        <url-pattern>
            /health/HealthLogin
        </url-pattern>
    </servlet-mapping>	
.... 

Now in the my url address if I give ~localhost:8080/health/HealthLogin it
gives me a error saying page cannot be found.

Please let me know what mistake I am doing here...
Thank You
Jags







-----Original Message-----
From: Richard Draucker [mailto:richard@protected-data.com]
Sent: Friday, August 17, 2001 7:42 PM
To: Jagadish Gopi
Subject: RE: Error when reading a servlet


I think what you're trying to accomplish is to create an alias for your 
servlet.  And while what you have sorta looks like it should work, its
really 
not the way tomcat does this.

I have created a Context within server.xml file, something of this sort

<Context path="/health" 
 
docBase="c:/jakarta-tomcat-3.2.1/webapps/com/health/wls/servlets" 
              crossContext="true"
              debug="0" 
              reloadable="true" >

 </Context>

First, make sure your context code is closed up rather than on multiple 
lines.  It may just have come out this way in the email, but I thought I'd 
mention it in case that's how you typed it. 

Second, the context is for the entire web application and can't reference a 
servlet.  It should be pointing to the root of a web application, which must

adhere to a defined structure.  For example...
<Context path="/health" docBase="webapps/health" etc...></Context>  //
Please tell me if I give in docbase as 			"webapps/health" how
will it know the exact servlet path... which is within
webapps/com/health/wls/servlets

Third, to make the servlet load as the default index page, the easiest way
is
to add a servlet mapping to the web.xml file in WEB-INF under your web 
application, the structure of which should define a path consistent with:
~webapps/health/WEB-INF/classes

The WEB-INF directory (caps required, even in Windows) will contain a
web.xml 
file, a sample one can be found in tomcat/lib along with the servlet.xml
file.
Add the following to the web.xml between the <webapp> tags.

    <servlet>
        <servlet-name>
           HealthLogin
        </servlet-name>
        <servlet-class>
           HealthLogin
        </servlet-class>
    </servlet>

    <servlet-mapping>
	<servlet-name>
	   HealthLogin
        </servlet-name>
        <url-pattern>
	/health/HealthLogin
        </url-pattern>
    </servlet-mapping>


This will cause the HealthLogin servlet to run when the url-pattern shown is

entered as the target addrss.   So the url: ~//localhost/index.html will
load 
an index.html file from the ~/webapps/health directory.  And  the url 
~//localhost/health/HealthLogin will run the HealthLogin servlet 










Mime
View raw message