You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "Valerdi Tormo, Jose" <JV...@es.wanadoo.com> on 2001/06/27 10:12:01 UTC

Adding Servlets to TOMCAT 3.2

Hi,

I'm trying to install new servlets under WEBAPPS directory in TOMCAT 3.2
(expecifically in the /services directory). I'm getting the next message
when I start TOMCAT after adding the directory with the files.

2001-06-27 10:10:44 - Ctx( /services ): Mapping with unregistered servlet
servletToJsp

Anybody know what does it mean? Why this message don't appear in the other
Context? If this one is an error, How can avoid it?

Thanks in advance for all

Regards,

Jose


-----Mensaje original-----
De: Stefan Neumann [mailto:stefan.neumann@netgrafics.de]
Enviado el: miércoles, 27 de junio de 2001 9:26
Para: tomcat-user@jakarta.apache.org
Asunto: RE: getServletContext()


Hi,

getAttribute returns a java.lang.Object so you have to cast it to
java.sql.Connection. You will also need to import java.sql.

<%@ page import="java.sql.*" %>
...
<% Connection Conn =
(Connection)getServletContext().getAttribute("dbConnection"); %>

Make sure dbConnection isn't null when you set the attribute, cause that
would be
another problem.

-----Original Message-----
From: JeremyRayYoo@aol.com [mailto:JeremyRayYoo@aol.com]
Sent: Dienstag, 26. Juni 2001 21:06
To: tomcat-user@jakarta.apache.org
Subject: getServletContext()


Hi, I have a problem I have been trying to solve for a very long time. I
first have a initialization servlet set by <load_on_startup> tag. In this
servlet I create a database connection and pass it to the ServletContext
like
this.

getServletContext().setAttribute("dbConnection",dbConnection);

Now the problem is how do I retrieve it from a jsp page. From by research,
reading through books it shows how to get an attribute using : jsp:useBean
action. However this is done if Beans/Objects are put into the setAttribute.
In my case it is a database connection object. How do I retrieve this from a
jsp page???
I tried (in a jsp page);
<% Connection connection = getServletContext().getAttribute("dbConnection");
%>
but this returns a null. Connection never gets set..
If someone can help me please......

AW: Adding Servlets to TOMCAT 3.2

Posted by Thomas Bezdicek <th...@engnetworld.com>.
Hi,

this means that you have a servlet-mapping rule in your web.xml
but you didnot define the servlet-name before.

<!-- This defines the servlet-name for later use -->
        <servlet>
                <servlet-name>MyName</servlet-name>
                <servlet-class>com.name.MyClass</servlet-class>
	  </servlet>

<!-- This defines a servlet-mapping -->
        <servlet-mapping>
                <servlet-name>MyName</servlet-name>
                <url-pattern>/MyPattern</url-pattern>
        </servlet-mapping>

regards, tom

> -----Ursprüngliche Nachricht-----
> Von: Valerdi Tormo, Jose [mailto:JValerdi@es.wanadoo.com]
> Gesendet: Mittwoch, 27. Juni 2001 10:12
> An: tomcat-user@jakarta.apache.org
> Betreff: Adding Servlets to TOMCAT 3.2
>
>
> Hi,
>
> I'm trying to install new servlets under WEBAPPS directory in TOMCAT 3.2
> (expecifically in the /services directory). I'm getting the next message
> when I start TOMCAT after adding the directory with the files.
>
> 2001-06-27 10:10:44 - Ctx( /services ): Mapping with unregistered servlet
> servletToJsp
>
> Anybody know what does it mean? Why this message don't appear in the other
> Context? If this one is an error, How can avoid it?
>
> Thanks in advance for all
>
> Regards,
>
> Jose
>
>
> -----Mensaje original-----
> De: Stefan Neumann [mailto:stefan.neumann@netgrafics.de]
> Enviado el: miércoles, 27 de junio de 2001 9:26
> Para: tomcat-user@jakarta.apache.org
> Asunto: RE: getServletContext()
>
>
> Hi,
>
> getAttribute returns a java.lang.Object so you have to cast it to
> java.sql.Connection. You will also need to import java.sql.
>
> <%@ page import="java.sql.*" %>
> ...
> <% Connection Conn =
> (Connection)getServletContext().getAttribute("dbConnection"); %>
>
> Make sure dbConnection isn't null when you set the attribute, cause that
> would be
> another problem.
>
> -----Original Message-----
> From: JeremyRayYoo@aol.com [mailto:JeremyRayYoo@aol.com]
> Sent: Dienstag, 26. Juni 2001 21:06
> To: tomcat-user@jakarta.apache.org
> Subject: getServletContext()
>
>
> Hi, I have a problem I have been trying to solve for a very long time. I
> first have a initialization servlet set by <load_on_startup> tag. In this
> servlet I create a database connection and pass it to the ServletContext
> like
> this.
>
> getServletContext().setAttribute("dbConnection",dbConnection);
>
> Now the problem is how do I retrieve it from a jsp page. From by research,
> reading through books it shows how to get an attribute using : jsp:useBean
> action. However this is done if Beans/Objects are put into the
> setAttribute.
> In my case it is a database connection object. How do I retrieve
> this from a
> jsp page???
> I tried (in a jsp page);
> <% Connection connection =
> getServletContext().getAttribute("dbConnection");
> %>
> but this returns a null. Connection never gets set..
> If someone can help me please......