Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-dev] How do I set a ServletContext attribute ?

Jean-Marc,

For both jetty6.x and jetty7.x it is:

For context attributes:
webappcontext.setAttribute(String, Object);

For context init params:
webappcontext.setInitParameter(String,String);

cheers
Jan

Jean-Marc Strydom wrote:
Hi
I am new to Jetty. I am currently involved in moving a webapp to run under embedded Jetty but need to set a ServletContext attribute at startup. I am using the following code to invoke Jetty:
Server server = *new* Server();

Connector connector = *new* SelectChannelConnector();

connector.setPort(port);

server.setConnectors(*new* Connector[] { connector });

WebAppContext webappcontext = *new* WebAppContext();

webappcontext.setContextPath("/myapp");

webappcontext.setWar("./");

server.setHandler(webappcontext);

server.start();

While this is very easy to setup, I don't see any way of getting the ServletContext in the class that invokes Jetty (which appears to be possible in Jetty6). I have looked through various examples on the net but they all refer to Jetty6. How can I do this in Jetty7?

Regards

Jean-Marc


------------------------------------------------------------------------

_______________________________________________
jetty-dev mailing list
jetty-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/jetty-dev

--
Jan Bartel, Webtide LLC | janb@xxxxxxxxxxx | http://www.webtide.com


Back to the top