With this course, we’re going to learn the Java Struts 2 Technology, presenting a Tomcat Web solution and exploring how a Finance Management Software can be designed using these resources.
In this tutorial, we’ll test a sample application generated by eclipse environment to Tomcat Web Server. After this, we’ll create an application using Struts 2. At this first time, will be a simple Hello World, but showing all information needed to provide you conditions to start up the process.
Java, Apache Struts 2, Eclipse, Tomcat
Keyword: Java, Eclipse, Struts 2, Tomcat, apache, hello, web
TranscriptHello everybody, please be welcome. Let's continue our Java Struts
tutorial. Right now we're going to create a new Tomcat application on
Eclipse environment. So, let's create it. Here we've got the Tomcat
project. You must give a name to this project. And here you must type a
context name. This context name will be used on Tomcat as a web folder. And
OK. So, the Eclipse 2. We will create all folders needed to begin our
project. In this first time we're going to create a simple Tomcat
application, just to prove how Tomcat works. So, here we go. You have a
folder named 'WEB-INF/Src', which is used for all the source code
needed. You have also a 'WEB-INF' and 'lib' folder, which is used for any
kind of Library Jar file that we are going to use on this project.
Let's create a new GSP file to test the Tomcat container. JSP file. Then
you must choose a name. We're going to choose Index.JSP. You mark this
option 'New GSP file' and then finish. And here you get the Index.JSP file.
Inside the body text we're going to type 'Hello world', just to prove if
our project will work. And right now we must simulate, or make a real
deploy to Tomcat application. So you can do it right inside your Eclipse 2.
Just click on mouse right button, and choose Tomcat project,
'Create JSP Work Directory'. Operation OK. After that, we're going to open
the web browser, and going to access the localhost, at port 8080. You
click on manager applications. You must type your user name and password.
And here you find your Tomcat Test Application here. Your application is
working because the start button is not available. And then you click on
the link 'Tomcast Test 01'. Here you've got your 'Hello World', and here
you've got your application working.
And after seeing this first deployment process, we must take a look at a
simple trick that will help us to understand how the Eclipse 2 updates, or
deployment made by that process. If you make any kind of change on your
source code, like this. This code will be automatically updated to your
Tomcat. You just have to open your web browser and type the main address
here, and the code will be updated. OK, it's here. Alright? I made a
mistake here, I'm sorry. Well, let's test again if this change has been
made. OK, it's here. It's done. This is very important because all changes
made it on a simple file, and if you just save this file, your main Tomcat
application will be updated. But, if you make any changes on the folders of
the application, like this, or adding some kind of Jar files or something
like this. you have to manually update your application, use the menu on
option Tomcat project, update context definition. It will be forced to
update the application on Tomcat.
Reviewing all the things made on this project. We just created a Tomcat
test project, like this. And we just added the Index file on the main root
folder. Now let's take a look at the Tomcat installation folder, to see
some important information that we must understand when using Tomcat 7, or
any other version of Tomcat. You have a folder named "Logs". Enter this.
And then you have a bunch of files all separated by date that you find all
logs that Tomcat will generate. Let's take these Log files made today. You
find this kind of structure here. And here you find all the information
needed to see any kind of problem that you will find in your development
process. Any kind of error generated. And the log access. OK? After this,
let's use the same logic applied on this first Tomcat application to create
a new application using the Struts on the main content. So, let's create a
new project folder. Let's find Java. Tomcat project. Project name. It will
be our first application: 'Struts Test 01'. OK, it will be created.
So, now we must understand all the components needed to make Struts run. We
have made a download from Struts webpage, containing the minimum
requirements to run Struts. I'm showing here these files, a lot of files.
But we will use just a few of them to create our minimal application using
Struts. Oh, I've made a match key right here. But here you'll find it's
done. Inside the 'Web-Int' folder, 'Lib' folder, you will find attached on
this solution, all the files needed to create the simple in your forced
application using Java Struts. You will find all these files inside that
folder that you already have downloaded, all of the main files from the
Struts website. And this is our brand new start, to create our first
application using Java Struts. OK, the library is done. Let's go to the
When we create a Struts application, the Struts application will demand two
configuration files that will be used to define some variables used in a
map for the Struts application. The first file, we will call it as a
Web.xml. So, create this file inside the 'Web Int' folder. Here. OK. And
here you must add all the main formations for the web application. The
Web.xml is used by the Tomcat to obtain how the application will work. At
this first time, and at this first application using Struts, I will just
copy and paste a code, just to show you how the things work on the Struts.
In this tutorial, we will design and create a Financial Manager Application
sample. To show you some functions and some ways to use the Struts. I have
already made this application, so I just copied the Web.xml just to show
you how the file works. We have a definition by a Web APP tech. A display
name, a name that will be displayed by Tomcat. You can type here the sample
Struts. OK. You can set a welcome file here, Index.JSP. A filter that will
be used by Struts, I will explain this later. And a filter mapping, used by
Struts also, here. These two texts, I will explain later how it works. At
this first time, let's just add this file on the solution, and after that
we will understand how the things are working. On the next class, I will
show you how to create the second XML file named Struts.xml. That's all for
now. Thank you. See you later.