Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Problem with tomcat 6.0.32

Reply
Thread Tools

Problem with tomcat 6.0.32

 
 
ruds
Guest
Posts: n/a
 
      09-05-2012
hi,
I'm am deploying an application having JSP's and few servlets. My servlet is not getting invoked after calling from JSP. My web.xml entry is:
<web-app>
<servlet>
<servlet-name>login</servlet-name>
<servlet-class>CheckLogin</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>login</servlet-name>
<url-pattern>/CheckLogin/* </url-pattern>
</servlet-mapping>
</web-app>

all my classes are in the WEB-INF/classes directory. On called by JSP I'm getting error as:
The requested resource (/CheckLogin) is not available.
I'm calling this from a JSP form element:
<FORM name="f1" ACTION="/CheckLogin" METHOD=POST onsubmit='return checkall()'>

please tell what might be causing this problem.
Thanks in advance.

 
Reply With Quote
 
 
 
 
markspace
Guest
Posts: n/a
 
      09-05-2012
On 9/4/2012 11:50 PM, ruds wrote:
> hi,
> I'm am deploying an application having JSP's and few servlets. My servlet is not getting invoked after calling from JSP. My web.xml entry is:
> <web-app>
> <servlet>
> <servlet-name>login</servlet-name>
> <servlet-class>CheckLogin</servlet-class>
> </servlet>
> <servlet-mapping>
> <servlet-name>login</servlet-name>
> <url-pattern>/CheckLogin/* </url-pattern>
> </servlet-mapping>
> </web-app>
>
> all my classes are in the WEB-INF/classes directory. On called by JSP I'm getting error as:
> The requested resource (/CheckLogin) is not available.
> I'm calling this from a JSP form element:
> <FORM name="f1" ACTION="/CheckLogin" METHOD=POST onsubmit='return checkall()'>
>
> please tell what might be causing this problem.



What is the context path for the web app? Can you show us the URL used
for the FORM above, and the URL of the /CheckLogin action that doesn't
work? Just cut and paste them both from the browser, don't try to
"figure them out." I want the host name too, even if it's "127.0.0.1"
or localhost.





 
Reply With Quote
 
 
 
 
ruds
Guest
Posts: n/a
 
      09-06-2012
the URL for my webapp is: http://localhost:8080/FIR/login.jsp
the URL which it gets directed to should be: http://localhost:8080/FIR/CheckLogin
but it is going at: http://localhost:8080/CheckLogin
 
Reply With Quote
 
Fredrik Jonson
Guest
Posts: n/a
 
      09-06-2012
In <5f8ee108-bcec-4f96-ac86-> ruds wrote:

> I'm am deploying an application having JSP's and few servlets. My servlet is
> not getting invoked after calling from JSP. My web.xml entry is:
>
> <servlet-mapping>
> <servlet-name>login</servlet-name>
> <url-pattern>/CheckLogin/* </url-pattern>
> </servlet-mapping>
>
> I'm calling this from a JSP form element:
> <FORM name="f1" ACTION="/CheckLogin" METHOD=POST onsubmit='return checkall()'>


You need to prepend the servlet context path to the form action url.

In html, when you specify a relative url that starts with a / it is
interpered as being relative to the server root. So /foo is interpreted
as http://example.com/foo. The servlet mapping in web.xml does normally
not start from the server root, but from the servlet context path.

--
Fredrik Jonson
 
Reply With Quote
 
markspace
Guest
Posts: n/a
 
      09-06-2012
On 9/5/2012 8:36 PM, ruds wrote:
> the URL for my webapp is: http://localhost:8080/FIR/login.jsp
> the URL which it gets directed to should be: http://localhost:8080/FIR/CheckLogin
> but it is going at: http://localhost:8080/CheckLogin
>



Yup, c.f. Fredrik's reply: the "action" from the form needs to either be
/FIR/CheckLogin, or it needs to be a relative URL -- "CheckLogin" with
no slash in front.

Your missing the context path, in other words, which is easy for newbies
to trip on.


 
Reply With Quote
 
Arne Vajhøj
Guest
Posts: n/a
 
      09-09-2012
On 9/6/2012 12:36 AM, Fredrik Jonson wrote:
> In <5f8ee108-bcec-4f96-ac86-> ruds wrote:
>
>> I'm am deploying an application having JSP's and few servlets. My servlet is
>> not getting invoked after calling from JSP. My web.xml entry is:
>>
>> <servlet-mapping>
>> <servlet-name>login</servlet-name>
>> <url-pattern>/CheckLogin/* </url-pattern>
>> </servlet-mapping>
>>
>> I'm calling this from a JSP form element:
>> <FORM name="f1" ACTION="/CheckLogin" METHOD=POST onsubmit='return checkall()'>

>
> You need to prepend the servlet context path to the form action url.


Or drop thw / entirely.

> In html, when you specify a relative url that starts with a / it is
> interpered as being relative to the server root. So /foo is interpreted
> as http://example.com/foo. The servlet mapping in web.xml does normally
> not start from the server root, but from the servlet context path.


That is almost certainly the problem.

But may I use the opportunity to mention that it should not be:

action="CheckLogin"

but:

action="<%=response.encodeURL("CheckLogin")%>"

to work with cookies disabled.

Something that is often forgotten today.

An even better solution would probably be to use a taglib that
handles all that stuff for one, but then we are somewhat changing
topic.

Arne



 
Reply With Quote
 
markspace
Guest
Posts: n/a
 
      09-09-2012
On 9/8/2012 7:33 PM, Arne Vajhøj wrote:

> action="<%=response.encodeURL("CheckLogin")%>"
>
> to work with cookies disabled.
>
> Something that is often forgotten today.



Huh, I must be missing something. "CheckLogin" is a hard-coded string
that plainly needs no encoding. What is it that I don't see?



 
Reply With Quote
 
Arne Vajhøj
Guest
Posts: n/a
 
      09-09-2012
On 9/8/2012 11:22 PM, markspace wrote:
> On 9/8/2012 7:33 PM, Arne Vajhøj wrote:
>
>> action="<%=response.encodeURL("CheckLogin")%>"
>>
>> to work with cookies disabled.
>>
>> Something that is often forgotten today.

>
> Huh, I must be missing something. "CheckLogin" is a hard-coded string
> that plainly needs no encoding. What is it that I don't see?


That encodeURL adds the session id to the URL if the browser
does not support cookies (or if it is unknown whether it support
cookies).

Arne


 
Reply With Quote
 
Arne Vajhøj
Guest
Posts: n/a
 
      09-09-2012
On 9/8/2012 11:25 PM, Arne Vajhøj wrote:
> On 9/8/2012 11:22 PM, markspace wrote:
>> On 9/8/2012 7:33 PM, Arne Vajhøj wrote:
>>
>>> action="<%=response.encodeURL("CheckLogin")%>"
>>>
>>> to work with cookies disabled.
>>>
>>> Something that is often forgotten today.

>>
>> Huh, I must be missing something. "CheckLogin" is a hard-coded string
>> that plainly needs no encoding. What is it that I don't see?

>
> That encodeURL adds the session id to the URL if the browser
> does not support cookies (or if it is unknown whether it support
> cookies).


It is well documented:

http://docs.oracle.com/javaee/6/api/...lang.String%29

but the cookies disabled scenario is not much on the radar
screen today.

Arne


 
Reply With Quote
 
markspace
Guest
Posts: n/a
 
      09-09-2012
On 9/8/2012 8:25 PM, Arne Vajhøj wrote:
> On 9/8/2012 11:22 PM, markspace wrote:
>> On 9/8/2012 7:33 PM, Arne Vajhøj wrote:
>>
>>> action="<%=response.encodeURL("CheckLogin")%>"
>>>
>>> to work with cookies disabled.
>>>
>>> Something that is often forgotten today.

>>
>> Huh, I must be missing something. "CheckLogin" is a hard-coded string
>> that plainly needs no encoding. What is it that I don't see?

>
> That encodeURL adds the session id to the URL if the browser
> does not support cookies (or if it is unknown whether it support
> cookies).


Ah right, I knew that, but I haven't used JSPs in so long I'd forgotten
it. Thanks!



 
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
Tomcat 6 / Apache 2.2 integration problem (no images / tomcat deploysto temp dir) Andi Java 5 03-20-2008 06:50 AM
tomcat-maven-plugin problem - mvn is looking for org.apache.maven.plugins:maven-tomcat-plugin Marcin Cenkier Java 1 04-12-2006 08:00 PM
Problem with Tomcat Service when Tomcat Installation pathname has double byte characters Rakesh Pandit Java 0 07-12-2005 06:25 AM
Apache Tomcat 4.1.24: problem with Tomcat Administration link Christos Gravvanis Java 0 07-07-2004 05:21 PM
[TOMCAT] Tomcat crashes %=zerointeractive.it% Java 1 01-22-2004 12:08 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57