Skip to main content

Struts Folder Structure in Tomcat (Apache)

Struts is one of the MVC Based Web frameworks in Java EE. It is used in creating simple web applications that are more flexible and easy to debug. Many of the blogs till have written about the folder structure of Struts and now i am going to discuss about the neat folder structure of struts in the Apache Tomcat version 7/6/5 or below.

The structure is mostly similar to that of the structure of the servlets/jsp. A little change can be noted here.


Note: Additional jar files in the lib directory may be needed example, struts-tiles-1.3.10.jar is necessary when you do use the tiles framework.

The classes directory: The classes directory should contain the relevant classes i.e. the Action class, Form Bean class (optional), MyRequestProcessor (Your own RequestProcessor class [Optional]), the Model class (optional). Optional means that these classes are not needed at all situations i.e. all applications. Usually a bean class and Model class is used when you interact with database. Helloworld example does not make use of these classes.

HTML Files: The HTML files and jsps are also seen in the servlets/jsp. So that is it.

web.xml: The web.xml file does the same thing as in the servlets. But with a little bit of change, later discussed on other posts.

struts-config.xml: This is the file that maps the action class for some user's request. It is specified in the web.xml file. Note: As is specified in the web.xml, you can rename struts-config.xml to myconfig.myext and can also change where it is located. Whatever you do, you must specify the complete path along with the name and extension of this file in the web.xml.

webapps: Webapps folder is the webapps folder in the Tomcat. It comes by default when you install your tomcat. 

Popular posts from this blog

Setting Background Image in JFrame - Swing

Here is sample tutorial, a simple trick that enables you to set background image for JFrame.

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
class BackgroundImageJFrame extends JFrame
JButton b1;
JLabel l1;
public BackgroundImageJFrame()
setTitle("Background Color for JFrame");
One way
setLayout(new BorderLayout());
JLabel background=new JLabel(new ImageIcon("C:\\Users\\Computer\\Downloads\\colorful design.png"));
background.setLayout(new FlowLayout());
l1=new JLabel("Here is a button");
b1=new JButton("I am a button");
// Another way
setLayout(new BorderLayout());
setContentPane(new JLabel(new ImageIcon("C:\\Users\\Computer\\Downloads\\colorful design.png")));
setLayout(new FlowLayout());
l1=new JLabel("Here is a button");
b1=new JButton("I am …

Catch The Rat: Simple Game in Java

A simple, shortest and easiest game that could be written in Java using Swing components and event handling.

Add two numbers in JSP easily

Here is an example on adding up two numbers in JSP. This is very simple as you see below. This requires very small piece of code. All i have done here is created a HTML file containing the input fields which contain the numbers to add up.Now the values in the input field are of type String, so i have done type casting and converted them into int using Integer.parseInt(). See how easy it looks.