Making Our Game Professional - Do it as a Webapp

In this chapter, we will program a web application. We will build on what we have achieved already and create a web version of the Mastermind game. This time, it will not only run alone, guessing and answering the number of positions and matched colors, but also communicate with the user asking for the answers to the guesses. This will be a real game. Web programming is extremely important for Java programmers. Most of the programs are web applications. The universal client available on the Internet is the web browser. The thin-client, web browser-based architecture is widely accepted in enterprises as well. There are only some exceptions when the architecture has something else but the web client. If you want to become a professional Java developer, you must be familiar with web programming. And it is also fun!

There are a lot of technical topics that we will visit during the development. First of all, we will discuss networking and web architecture. This is the concrete base of the whole building. It is not too sexy, just like when you construct the building. You spend a lot of money and effort digging trenches, and then you bury the concrete and end up at the end of the phase with what you seemingly had before: flat ground. Except that there is the base. Building without this base, the house would either collapse soon after or during the process of building. Networking is just as important for web programming. There are a lot of topics that seemingly have nothing to do with programming. Still, it is the base of the building and when you program web applications, you will also find the fun part in it.

We will also talk a bit about HTML, CSS, and JavaScript, but not too much. We cannot avoid them because they are also important for web programming, but they are topics that you can learn from somewhere else as well. In case you are not an expert in some of these areas, there are usually other experts in enterprise project teams who can extend your knowledge. (In the case of networking, there is no mercy.) In addition to that, JavaScript is a topic so complex and huge that it deserves a whole book to start with it. There are only very few experts who deeply understand both Java and JavaScript. I understand the general structure of the language and the environment it runs in, but I cannot keep up with the new frameworks that are released every week these days, having my focus on other areas.

You will learn how to create Java applications that run in an application server, this time in Jetty, and we will see what a servlet is. We will create a web hello world application to start up fast, and then we will create the servlet version of Mastermind. Note that we hardly ever program servlets directly without the aid of some framework that implements the code to handle parameters, authentication, and many other things that are not application-specific. We will still stick to a naked servlet in this chapter because it is not possible to effectively use frameworks, such as Spring, without first understanding what a servlet is. Spring will come in the next chapter.

We will mention Java Server Pages (JSP) only because you may meet some legacy application, which was developed using that technology, but modern web applications do not use JSP. Still, JSP is a part of the servlet standard and is available for use. There are other technologies that were developed in the recent past but do not seem to be future-proof these days. They are still usable but appear only in legacy applications, and choosing them for a new project is fairly questionable. We will talk about these technologies shortly in a separate section.

By the end of this chapter, you will understand how the basic web technology works and what the major architectural elements are, and you will be able to create simple web applications. This is not enough to be a professional Java web developer but will be a good grounding for the next chapter, where we will have a look at the professional frameworks used in today's enterprises for real application developments.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.173.199