ServletContextAdapter in 2.0?

3 messages Options
Embed this post
Permalink
webpost

ServletContextAdapter in 2.0?

Reply Threaded More More options
Print post
Permalink
In 1.1 I do this to get the ServletContext. How do I get the ServletContext in 2.0?


ServletContextAdapter adapter = (ServletContextAdapter) getContext();

ServletContext servContext = (ServletContext) adapter.getContext();

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=7458&dsMessageId=2379919
webpost

RE: ServletContextAdapter in 2.0?

Reply Threaded More More options
Print post
Permalink
Hi,

Can somebody help me with this? I'm rewriting a project from Restlet 1.1 to 2.0 but some classes in 2.0 are deprecated like ServletContextAdapter. I have an existing Servlet which load a properties file in the context and i need that to load the properties in my application.

Here's a sample code in 1.1.

private Properties getAppProperties()
throws Exception
{

//Get ServletContext where the //'appProperties' is loaded

ServletContextAdapter adapter = (ServletContextAdapter) getContext();

ServletContext servContext = (ServletContext) adapter.getContext();

           
Properties appProperties = (Properties) servContext.getAttribute("appProperties");

return appProperties;
}

Now how do I do that in 2.0?

Thanks and Regards,
Robin


> In 1.1 I do this to get the ServletContext. How do I get the ServletContext in 2.0?
>
>
> ServletContextAdapter adapter = (ServletContextAdapter) getContext();
>
> ServletContext servContext = (ServletContext) adapter.getContext();

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=7458&dsMessageId=2380681
jlouvel

RE: ServletContextAdapter in 2.0?

Reply Threaded More More options
Print post
Permalink
Hi Robin,

This is more a question for the [hidden email] list...

This change was made after 2.0 M3:

        - ServerServlet nows copies the ServletContext into a special
          "org.restlet.ext.servlet.ServletContext" attribute of both
          the Component's context and the Application's context.

We are about to release 2.0 M4 (today), so you can either wait for it or
download a recent snapshot.

Best regards,
Jerome Louvel
--
Restlet ~ Founder and Lead developer ~ http://www.restlet.org
Noelios Technologies ~ Co-founder ~ http://www.noelios.com




-----Message d'origine-----
De : [hidden email] [mailto:[hidden email]]
Envoyé : jeudi 6 août 2009 04:32
À : [hidden email]; [hidden email]
Objet : RE: ServletContextAdapter in 2.0?

Hi,

Can somebody help me with this? I'm rewriting a project from Restlet 1.1 to
2.0 but some classes in 2.0 are deprecated like ServletContextAdapter. I
have an existing Servlet which load a properties file in the context and i
need that to load the properties in my application.

Here's a sample code in 1.1.

private Properties getAppProperties()
throws Exception
{

//Get ServletContext where the //'appProperties' is loaded

ServletContextAdapter adapter = (ServletContextAdapter) getContext();

ServletContext servContext = (ServletContext) adapter.getContext();

           
Properties appProperties = (Properties)
servContext.getAttribute("appProperties");

return appProperties;
}

Now how do I do that in 2.0?

Thanks and Regards,
Robin


> In 1.1 I do this to get the ServletContext. How do I get the
ServletContext in 2.0?
>
>
> ServletContextAdapter adapter = (ServletContextAdapter) getContext();
>
> ServletContext servContext = (ServletContext) adapter.getContext();

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=7458&dsMessageId=23806
81

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=7458&dsMessageId=2380724