".
This is all working fine, apart from one issue: a call to HttpServletRequest.getServletContext() returns "/"
rather than "" - the servlet API says "" is correct . If the default context is defined in
server.xml, getServletContext() returns "" a
You must call super.init(...) in your init method.
-Tim
Luke Vanderfluit wrote:
Hi,
I found that using the init() method to set up a database connection
then trying to instantiate a ServletContext object and forward to a jsp
page didn't work.
If placed the database connection code in the doPo
etParameter("descr");
try
{
// Declare statement
Statement statement = dbcon.createStatement();
String query = "insert into bookmark values('"
+ title + "', '" + url + "', '" + descr + "'
n
from below.
Padhu Vinirs wrote:
>
> Wanted to know if this assumption is valid in most jsp containers:
>
> Is calling getServletContext() ( instead of
> getServletConfig().getServletContext() ) assuming that the servlet
> generated from the jsp will be derived from HttpS
Wanted to know if this assumption is valid in most jsp containers:
Is calling getServletContext() ( instead of
getServletConfig().getServletContext() ) assuming that the servlet
generated from the jsp will be derived from HttpServlet ?
This works ( in Tomcat ) because HttpJspBase derives
.");
> ois.defaultReadObject();
> System.out.println("defaultReadObject completed...");
> ServletContext sc = getServletContext(); // BOOM!!
> System.out.println("Got the servlet context!!!");
> } // readObject()
>} // Inner
I j
Please ignore the previous message I found the problem and it was just a
mistake on my side.
-Original Message-
From: Jeff Macomber [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, April 17, 2002 5:39 PM
To: 'Tomcat Users List'
Subject: getServletContext() error
Hi all,
I am
Hi all,
I am trying to share an object from a servlet to a JSP by using the
getServletContext().setAttribute() method in the init() of my servlet. I am
able to return the context from the JSP page but am unable to retrieve the
attribute (getAttribute() returns null).
I have setup the Context
On Mon, 14 Jan 2002 09:59:49 -0500 you wrote:
> The easiest way to get this behavior is to override
> init(ServletConfig config) in your servlet and forget
> to call super.init(config) as instructed in the Javadoc.
> You can either call super.init(config), or override
> init() instead, which is c
> -Original Message-
> From: Stan [mailto:[EMAIL PROTECTED]]
> Sent: Monday, January 14, 2002 9:39 AM
> To: [EMAIL PROTECTED]
> Subject: getServletContext() returning null...
>
>
> I have a servlet in which I am trying to pass control to a JSP page to
> conform with the
to
dispatch the request over to the JSP I get null back from the
getServletContext() call. Is there anything in the configuration I have
supplied which would stop this context being created appropriately? I would
presume that a servlet would necessarily be part of a ServletContext, and
therefore it
found it... I didn't call super.init(config) in the init() method
sorry
Stefanos
Stefanos Karasavvidis wrote:
> I've just installed tomcat 3.2.2 and have the following problem.
>
> I want to call getServletContext() from a servlets service method but
> get the folowing
sure to call the superclass' init() method?
-- Bill K.
> -Original Message-
> From: Stefanos Karasavvidis [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, July 10, 2001 7:46 AM
> To: [EMAIL PROTECTED]
> Subject: getServletContext() t
Did you override init(ServletConfig config) method?
YOu must call super(config) if you did...
--V.
-Original Message-
From: Stefanos Karasavvidis [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, July 10, 2001 7:46 AM
To: [EMAIL PROTECTED]
Subject: getServletContext() throws NullPoinetException
[EMAIL PROTECTED]
> Subject: getServletContext() throws NullPoinetException
>
>
> I've just installed tomcat 3.2.2 and have the following problem.
>
> I want to call getServletContext() from a servlets service method but
> get the folowing exception
> *Internal Servl
I've just installed tomcat 3.2.2 and have the following problem.
I want to call getServletContext() from a servlets service method but
get the folowing exception
*Internal Servlet Error:*
java.lang.NullPointerException
at javax.servlet.GenericServlet.getServletCo
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
I guess to save any object to a session, the object has to implement serializable
interface.
anil
ass 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 :
Hi, I have a problem I have been trying to solve for a very long time. I
first have a initialization servlet set by tag. In this
servlet I create a database connection and pass it to the ServletContext like
this.
getServletContext().setAttribute("dbConnection",dbConnection);
Now t
<% out.print(i); %>
> <% out.print(aResult.elementAt(i)); %>
>
> <% } %>
>
>
>
>
>
> > -Original Message-
> > From: Milt Epstein [SMTP:[EMAIL PROTECTED]]
> > Sent: Tuesday, March 13, 2001 3:27 PM
>
<% } %>
> -Original Message-
> From: Milt Epstein [SMTP:[EMAIL PROTECTED]]
> Sent: Tuesday, March 13, 2001 3:27 PM
> To: [EMAIL PROTECTED]
> Subject: RE: getServletContext null pointer exception
>
> On Tue, 13 Mar 2001 [EMAIL PROTECTED] wrote:
On Tue, 13 Mar 2001 [EMAIL PROTECTED] wrote:
> Yup, the jsp is in webapps/jdbctut/jdbctut.jsp
>
> This is where i get the err.
>
> if i use this stmt.
> ==> String value = getServletContext().getInitParameter("dbuser");
>
> or if i use this stmt
> =
Yup, the jsp is in webapps/jdbctut/jdbctut.jsp
This is where i get the err.
if i use this stmt.
==> String value = getServletContext().getInitParameter("dbuser");
or if i use this stmt
==>
System.out.println(getServletConfig().getServletContext().getInitParameter
or if i
; -Original Message-
> > From: Milt Epstein [SMTP:[EMAIL PROTECTED]]
> > Sent: Saturday, March 10, 2001 9:26 AM
> > To: [EMAIL PROTECTED]
> > Subject:Re: getServletContext null pointer exception
> >
> > On Fri, 9 Mar 2001 [EMAIL PROTECTED] wro
age-
> From: Milt Epstein [SMTP:[EMAIL PROTECTED]]
> Sent: Saturday, March 10, 2001 9:26 AM
> To: [EMAIL PROTECTED]
> Subject: Re: getServletContext null pointer exception
>
> On Fri, 9 Mar 2001 [EMAIL PROTECTED] wrote:
>
> > Hi,
> >
> > I have been
ing connect() {
> try {
>Class.forName("com.informix.jdbc.IfxDriver").newInstance();
>return "Driver Loaded!";
> } catch (Exception E) {
>return "Unable to load driver.";
> }
>}
>
>public String select() {
> //S
{
return "Unable to load driver.";
}
}
public String select() {
// String value = getServletContext().getInitParameter("dbuser");
//
System.out.println(getServletConfig().getServletContext().getInitParameter("
dbuser"));
ServletConfig sc = getSe
On Thu, 07 Dec 2000 19:15:47 -0600, William Brogden wrote:
>
>
>andreas ebbert wrote:
>>
>> Hi,
>> I am trying to get a servlets context
>> with getServletContext() but all I get
>> is a NullPointerException. Can anybody
>> help me?
>>
>>
andreas ebbert wrote:
>
> Hi,
> I am trying to get a servlets context
> with getServletContext() but all I get
> is a NullPointerException. Can anybody
> help me?
>
> greetings,
> Andreas
The usual reason for this is a failure to call super.init()
in your servlet
Hi,
I am trying to get a servlets context
with getServletContext() but all I get
is a NullPointerException. Can anybody
help me?
greetings,
Andreas
---
Andreas Ebbert, Kuthstrasse 43, 51107 Koeln
e-mail: [EMAIL PROTECTED]
Fon
31 matches
Mail list logo