Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / October 2005

Tip: Looking for answers? Try searching our database.

Jetty - adding context after starting server

Thread view: 
acilelaure - 10 Oct 2005 09:01 GMT
hello ng,

i have a problem with adding contexts to jetty after the server has
been already been started.
my code looks like:

[...]
HttpServer server = new HttpServer();
HttpListener listener = new ....
server.addListerner();
server.start();

HttpContext context = server.getContext(¨/user");
context.setResourceBase("/home/ich/access");
context.addHandler(new ResourceHandler());
context.addHandler(new FileNotFoundHandler());
server.addContext(context);
[...]

here i just create a context for /user. but when i try to acces
localhost:8080/ jetty says, it only has a context for /user. but, when
i try to access localhost:8080/user i get FileNotFound message.
is it possible to add und remove context after starting the server?
what is wrong with my code?

thx
bastian
Ross Bamford - 11 Oct 2005 12:21 GMT
> hello ng,
>
[quoted text clipped - 23 lines]
> thx
> bastian

It's been a bit since I worked with Jetty's internals, but IIRC isn't  
HttpContext separately lifecycled...? Hang on ( /me checks javadoc at  
http://jetty.mortbay.org/javadoc/index.html ... )

Yes, it looks like you don't need the addContext call (though I'm not  
sure), and you'd probably need to call context.start()  somewhere in there.

At the same time, what happens if you remove the FileNotFoundHandler? Are  
you sure the files really are there? And readable by the server process?

Signature

Ross Bamford (rosco@roscopeco.remove.co.uk)

Bastian - 13 Oct 2005 11:19 GMT
hi ross,

yes, you are right!
no addContext call needed - it doesnt matter if.
the point was the missing context.start() .
thank you very much.

bastian


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.