Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > servlet accessed from url with subdirectory

Reply
Thread Tools

servlet accessed from url with subdirectory

 
 
Steve
Guest
Posts: n/a
 
      01-23-2007
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?

 
Reply With Quote
 
 
 
 
=?ISO-8859-1?Q?Arne_Vajh=F8j?=
Guest
Posts: n/a
 
      01-23-2007
Steve wrote:
> 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
 
Reply With Quote
 
 
 
 
Steve
Guest
Posts: n/a
 
      01-23-2007
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

Arne Vajh°j wrote:
> Steve wrote:
>> 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

 
Reply With Quote
 
=?ISO-8859-1?Q?Arne_Vajh=F8j?=
Guest
Posts: n/a
 
      01-23-2007
Steve wrote:
> Arne Vajh°j wrote:
>> Steve wrote:
>>> 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.


> 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
 
Reply With Quote
 
Steve
Guest
Posts: n/a
 
      01-23-2007
Arne Vajh°j wrote:
> Steve wrote:
>> Arne Vajh°j wrote:
>>> Steve wrote:
>>>> 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.

>
> > 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

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.
 
Reply With Quote
 
Juha Laiho
Guest
Posts: n/a
 
      01-28-2007
Steve <(E-Mail Removed)> said:
>Arne Vajh°j wrote:
>> Steve wrote:
>>> Arne Vajh°j wrote:
>>>> Steve wrote:
>>>>> 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).


.... while having the following declarations in web.xml ...

>>>> <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>


>> What error do you get ?
>>

>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.
--
Wolf a.k.a. Juha Laiho Espoo, Finland
(GC 3.0) GIT d- s+: a C++ ULSH++++$ P++@ L+++ E- W+$@ N++ !K w !O !M V
PS(+) PE Y+ PGP(+) t- 5 !X R !tv b+ !DI D G e+ h---- r+++ y++++
"...cancel my subscription to the resurrection!" (Jim Morrison)
 
Reply With Quote
 
Steve
Guest
Posts: n/a
 
      02-02-2007
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

Juha Laiho wrote:
> Steve <(E-Mail Removed)> said:
>> Arne Vajh°j wrote:
>>> Steve wrote:
>>>> Arne Vajh°j wrote:
>>>>> Steve wrote:
>>>>>> 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).

>
> ... while having the following declarations in web.xml ...
>
>>>>> <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>

>
>>> What error do you get ?
>>>

>> 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.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how can I get the servlet access url from servlet context shaoanqing@gmail.com Java 4 04-20-2007 09:10 AM
ideas on URL names for web sites accessed via PocketPC Patino ASP .Net Mobile 0 02-17-2007 07:18 PM
redirect URL's, return URL's, and URL Parameters Jon paugh ASP .Net 1 07-10-2004 05:29 AM
Servlet question(Tomcat, web.xml, servlet-class, servlet-name) circuit_breaker Java 2 04-04-2004 03:26 AM
Servlets: How to reinitialize a variable each time the servlet is accessed ? Multicoder4002 Java 2 02-05-2004 03:01 PM



Advertisments