Desenvolvimento jsp

Disponível somente no TrabalhosFeitos
  • Páginas : 18 (4265 palavras )
  • Download(s) : 0
  • Publicado : 27 de novembro de 2012
Ler documento completo
Amostra do texto
Introducing JSP and Tomcat
Interactivity is what makes the Web really useful. By interacting with a remote server, you can find the information you need, keep in touch with your friends, or
purchase something online. And every time you type something into a web form, an application “out there” interprets your request and prepares a web page to respond.
To understand JSP, you first need tohave a clear idea of what happens when you ask your browser to view a web page, either by typing a URL into the address
field of your browser or by clicking on a hyperlink. Figure 1-1 shows you how it works.
Figure 1-1. Viewing a plain HTML page
The following steps show what happens when you request your browser to view a static web page:
1. When you type an address such as into the address field, your browser first resolves (i.e., the name of the web server) into the corresponding Internet Protocol (IP) address, usually by asking the Domain
Name Server provided by your Internet Service Provider (ISP). Then your browser sends an HTTP request to the newly found IP address
to receive the content of the file identified by/path/whatever.html.
2. In reply, the web server sends an HTTP response containing a plain-text HTML page. Images and other non-textual components, such as
sound and video clips, only appear in the page as references.
3. Your browser receives the response, interprets the HTML code contained in the page, requests the non-textual components from the
server, and displays the lot.
JavaServer Pages(JSP) is a technology that helps you create such dynamically generated pages by converting script files into executable Java modules;
JavaServer Faces (JSF) is a package that facilitates interactivity with the page viewers; and Tomcat is an application that can execute your code and act as a web server
for your dynamic pages.
Everything you need to develop JSP/JSF web applications is available forfree download from the Internet; but to install all the necessary packages and tools and
obtain an integrated development environment, you need to proceed with care. There is nothing more annoying than having to deal with incorrectly installed software.
When something doesn’t work, the problem will always be difficult to find.
In this chapter, I’ll introduce you to Java servlets and JSP, andI’ll show you how they work together within Tomcat to generate dynamic web pages. But, first of
all, I will guide you through the installation of Java and Tomcat: there wouldn’t be much point in looking at code you can’t execute on your PC, would there?
You’ll have to install more packages as you progress. Do these installations correctly, and you will never need to second guess yourself. Intotal, you will need at
least 300MB of disk space for Java and Tomcat alone and twice as much space to install the Eclipse development environment.
To run all the examples contained in this book, I used a PC with a 2.6GHz AMD Athlon 64x2 (nothing fancy, nowadays) with 1GB of memory and running
Windows Vista SP2. Before performing any installation, I reformatted the hard disk and re-installed theOS from the original DVD. I don’t suggest for a moment
that you do the same! I did it for two opposite but equally important reasons: first, I didn’t want existing stuff to interfere with the latest packages needed for web
development; second, I didn’t want to rely on anything already installed. I wanted to be sure to give you the full list of what you need.
At the time of this writing, thelatest versions of all the packages you will need to install are:
Java: 1.7.0 update 3 (installation explained in this chapter)
Tomcat web server: 7.0.26 (installation also explained in this chapter)
Eclipse development environment: Indigo 3.7.2 (installation explained in Chapter 2)
MySQL database: (installation explained in Chapter 6)
MySQL Java database connector (JDBC): 5.1.18...