Java Web Project
This note discusses an older Java project that utilizes the Struts framework.
Directory
src/main/java is a conventional Java Source Path, it can be configured in IDE, e.g. .vscode, it is a workspace specific setting
.myeclipse: created by MyEclipse IDE
.classpath: created by Eclipse IDE
.project: created by Eclipse IDE
Build process
compile all java code to class files under webapp/WEB-INF/classes
javac -d webapp/WEB-INF/classes src/main/java/**/*.java
build will copy the struts.xml under src/main/resources to webapp/WEB-INF/classes
cp src/main/resources/struts.xml webapp/WEB-INF/classes
package to WAR, package all things under webapp directory
jar -cvf /path/to/target/xxx.war *
make build.sh executable
chmod +x build.sh
Java Web Technology
JavaServer Pages
JavaServer Pages (JSP) is a technology that helps software developers create dynamically generated web pages based on HTML, XML, or other document types.
JavaServer Pages Scriptlet Expression <%= %> is used to embed Java code into the HTML page. It allows developers to write Java code that can be executed on the server side, and the result can be included in the HTML output sent to the client.
JavaServer Pages Expression Language (EL) ${} is a scripting language used in JSP to access application data stored in JavaBeans components, request parameters, and other objects. It provides a simple way to access and manipulate data without writing complex Java code.
JavaServer Pages Tag Library (JSTL) is a collection of tags that encapsulate core functionality common to many JSP applications. It provides tags for iteration, conditionals, internationalization, and more, making it easier to develop JSP pages without writing extensive Java code.
JSP directive is used to provide global information about an entire JSP page. It can be used to import Java classes, set page attributes, and define scripting variables.
FreeMarker template
FreeMarker is a template engine that separates presentation from business logic. Templates are written in a special syntax and filled with data at runtime, usually by a servlet or controller. FreeMarker encourages a clean separation of concerns and is often used as an alternative to JSP for rendering views.
Struts
Apache Struts is a popular open-source framework for building web applications in Java. It follows the Model-View-Controller (MVC) design pattern, which separates the application logic into three interconnected components: the model (data), the view (user interface), and the controller (business logic).
Struts was highly popular in the early 2000s as one of the first mainstream Java web frameworks, widely adopted for enterprise applications. Its popularity declined in the 2010s with the rise of more modern frameworks like Spring MVC and JavaServer Faces (JSF), which offered improved features and flexibility. In recent years, Struts has seen reduced usage, partly due to security concerns and the evolution of web development practices. Today, it is considered legacy technology, and most new Java web projects use alternative frameworks.
Struts 2.3 to 2.5 migration https://cwiki.apache.org/confluence/display/WW/Struts+2.3+to+2.5+migration#Struts2.3to2.5migration-StrutsPrepareAndExecuteFilter
Struts 2.5 to 6.0 migration https://cwiki.apache.org/confluence/display/WW/Struts+2.5+to+6.0.0+migration#Struts2.5to6.0.0migration-DTD