servlet accessed from url with subdirectory

S

Steve

I have a servlet that I'd like to access with a url that includes a
subdirectory; e.g., www.whatever.com/mysubdir/MyServlet (because that
subdirectory is a protected area with associated jsp's).

But, I can't seem to get a configuration that will map a request to the
servlet. I tried the following in web.xml to no avail:

<servlet>
<servlet-name>XServlet</servlet-name>
<servlet-class>XServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>XServlet</servlet-name>
<url-pattern>/mysubdir/com.whatever.XServlet</url-pattern>
</servlet-mapping>

How do I accomplish this?
 
?

=?ISO-8859-1?Q?Arne_Vajh=F8j?=

Steve said:
I have a servlet that I'd like to access with a url that includes a
subdirectory; e.g., www.whatever.com/mysubdir/MyServlet (because that
subdirectory is a protected area with associated jsp's).

But, I can't seem to get a configuration that will map a request to the
servlet. I tried the following in web.xml to no avail:

<servlet>
<servlet-name>XServlet</servlet-name>
<servlet-class>XServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>XServlet</servlet-name>
<url-pattern>/mysubdir/com.whatever.XServlet</url-pattern>
</servlet-mapping>

How do I accomplish this?

<servlet>
<servlet-name>XServlet</servlet-name>
<servlet-class>com.whatever.XServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>XServlet</servlet-name>
<url-pattern>/mysubdir/XServlet</url-pattern>
</servlet-mapping>

would be my guess.

Arne
 
S

Steve

Sorry,

That's what I actually did have. In my editing to remove the real site
names, etc., I got it backwards. But what you wrote matches the
format of the code in my web.wml, which doesn't work.

Steve
 
?

=?ISO-8859-1?Q?Arne_Vajh=F8j?=

> That's what I actually did have. In my editing to remove the real site
> names, etc., I got it backwards. But what you wrote matches the format
> of the code in my web.wml, which doesn't work.

What error do you get ?

Arne
 
J

Juha Laiho

.... while having the following declarations in web.xml ...
I I try to access it with the URL above, I get a message "Apache - Not
Found" and a blurb about configuring virtual paths. I I try a route
through servlet (www.whatever.com/servlet/MyServlet) I get a "requested
resource is not available" message.

.... ok; what do you see in your server error logs?

Also, note that web.xml is sensitive to the element order. So, for example,
you cannot interleave several <servlet> and <servlet-mapping> elements.
Instead, you must have all the <servlet> elements one after another in
your web.xml, and only after the last <servlet> can you have the first
<servlet-mapping>. Also, placement of <servlet> and servlet-mapping>
elements in relation to the other web.xml elements is critical.
 
S

Steve

Thanks for the reminder about that -- I did have one out of order.
But, sad to say, that didn't fix the problem. Upon further research, I
found that none of my mapings are taking. Nor are my filter definitions,
for that mater. Possibly related, my datasource doesn't work either.

Is there a way to ask Tomcat what mappings it currently has?


Steve
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top