aspose file tools*
The moose likes Servlets and the fly likes Is this the way to use Servlets? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Is this the way to use Servlets?" Watch "Is this the way to use Servlets?" New topic
Author

Is this the way to use Servlets?

Jorge Antonio Diaz-Benito Soriano
Greenhorn

Joined: Jul 17, 2013
Posts: 2
Hello,

I'm a software engineering student. I have a couple of years of intense experience with Java SE, and now I'm looking to learn something new. I wanted to focus on servlets, which seem the proper way to work with servers and Java technologies. I've been thinking of an example I could implement and I've came with the following one: a small scale simulation of the core of an online shop, like Amazon for example. The users could buy stuff either through the webpage or through mobile applications. I'd have a Java SE-based daemon to listen for the requests from the mobile applications, and then if all conditions (payment stuff and so) are met, the daemon runs the servlet which processes the bought, acting on a database or something. If the boughts are performed through the webpage, the conditions would be check on it with a typical buying module, and on success the servlet would be run.

This said, is this what servlets are used for?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61437
    
  67

Jorge Antonio Diaz-Benito Soriano wrote:I'd have a Java SE-based daemon to listen for the requests

No. The server is not something that you would write -- you'd use one of the existing servlet containers: Tomcat, Resin, Glassfish, etc. Servlets are executed by the servlet container, not by your own code.

This said, is this what servlets are used for?

Yes. Servlets are part of the server-side solution (along with JSP, beans, JDBC or ORM and more), but not in that way that you are currently thinking.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61437
    
  67

This article might help you understand how web applications are structured.
Jorge Antonio Diaz-Benito Soriano
Greenhorn

Joined: Jul 17, 2013
Posts: 2
Bear Bibeault wrote:This article might help you understand how web applications are structured.


I can't deep read it right now, but I've made an overview and it looks pretty well, it has gone straight into my bookmarks, thanks.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16145
    
  21

There is a lot of difference between Java SE and Java EE (formerly J2EE). It's the same Java language, the same core classes, but JEE adds a very large set of JEE-specific classes to the core class set. So to start with, get a good book on J2EE or JEe and learn the theory before you start coding. You need to understand how HTTP works, what a WAR is, and a lot of other stuff.

To actually begin working with Java EE, you need a suitable server, and if the goal is to implement a JEE webapp, then you definitely don't want to spend the time writing your own server. One of the most popular "starting" J2EE servers is Apache Tomcat. It doesn't incorporate the full J2EE/JEE feature set, but it does support the core JSP and servlet functionality. In fact, it incorporates it so well, that Tomcat is often embedded within full-stack implementations such as JBoss and JoNaS.

Tomcat is (probably) easier to get set up and working than most of the full-stack server systems, and is generally MUCH faster to start up and shut down (which is handy when you're doing a lot of experimental stuff). And I hear that the JavaRanch provides pretty good help for people with Tomcat problems.


Customer surveys are for companies who didn't pay proper attention to begin with.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Is this the way to use Servlets?