views:

380

answers:

2

Hi, I am very new to creating webservers - and I have had several goes at trying to understand them and write a quick webserver, but it's never quite 'clicked'. At the moment I am under the impression that REST would be most suitable for my purposes (I will explain later).

Can anyone either show me a basic code example in Java (using Tomcat Apache) or a tutorial resource to show how a webserver:

  • Can be used for security - i.e. pass in some kind of value to identify the client - from their the webserver will either deny or grant access to the client dependant on some criteria - maybe a lookup list.
  • Once the client is successfully accepted they will be allowed to pass in some more values to the webserver that will be used to write a row in a database table.

Many thanks.

PS - I would have thought there might have been soemthing that comes with Eclipse Ganymede? If someone can confirm?

+2  A: 

The best way to write restful resources in Java is via the JAX-RS standard. So I'd recommend you download Jersey which is the JAX-RS reference implementation and check out its examples; its got lots of them. Take an example for a spin then try hacking it to do what you like.

BTW JAX-RS can be run inside any Servlet engine - you just build a WAR and deploy it (there are examples in the Jersery samples) - though Jersey also comes with a small lightweight web server you can use too which is a little easier to use - again there are examples in the distro of this.

James Strachan
I will check it out. Cheers
Vidar
+1  A: 

I would also suggest that you look at Restlet

Darrel Miller