Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import org.apache.struts.helloworld.model.MessageStore;
import org.apache.struts2.ActionSupport;
import org.apache.struts2.interceptor.parameter.StrutsParameter;

/**
* Acts as a Struts 2 controller that responds
Expand Down Expand Up @@ -33,6 +34,7 @@ public String getUserName() {
return userName;
}

@StrutsParameter
public void setUserName(String userName) {
this.userName = userName;
}
Expand Down
5 changes: 4 additions & 1 deletion coding-actions/src/main/webapp/WEB-INF/web.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<web-app id="WebApp_ID" version="6.0"
xmlns="https://jakarta.ee/xml/ns/jakartaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/web-app_6_0.xsd">
<display-name>Coding Actions</display-name>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
Expand Down
7 changes: 7 additions & 0 deletions exception-handling/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@

<packaging>war</packaging>

<dependencies>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-config-browser-plugin</artifactId>
</dependency>
</dependencies>

<build>
<finalName>exception-handling</finalName>
<plugins>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import org.apache.struts.helloworld.model.MessageStore;
import org.apache.struts2.ActionSupport;
import org.apache.struts2.interceptor.parameter.StrutsParameter;

/**
* Acts as a Struts 2 controller that responds
Expand Down Expand Up @@ -37,6 +38,7 @@ public String getUserName() {
return userName;
}

@StrutsParameter
public void setUserName(String userName) {
this.userName = userName;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import org.apache.struts.register.exceptions.SecurityBreachException;
import org.apache.struts.register.model.Person;
import org.apache.struts2.ActionSupport;
import org.apache.struts2.interceptor.parameter.StrutsParameter;

/**
* Acts as a controller to handle actions related to registering a user.
Expand Down Expand Up @@ -43,6 +44,7 @@ public void throwSecurityException() throws SecurityBreachException {
"Security breach exception thrown from throwSecurityException");
}

@StrutsParameter(depth = 1)
public Person getPersonBean() {

return personBean;
Expand Down
7 changes: 6 additions & 1 deletion exception-handling/src/main/resources/struts.xml
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,13 @@
<result name="success">/HelloWorld.jsp</result>
</action>

<action name="registerForm">
<result>/register.jsp</result>
</action>

<action name="register" class="org.apache.struts.register.action.Register" method="execute">
<result name="success">/thankyou.jsp</result>
<result name="success">/thankyou.jsp</result>
<result name="input">/register.jsp</result>
</action>

</package>
Expand Down
19 changes: 11 additions & 8 deletions exception-handling/src/main/webapp/WEB-INF/web.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>Exception Handling</display-name>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>


<web-app id="WebApp_ID" version="6.0"
xmlns="https://jakarta.ee/xml/ns/jakartaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/web-app_6_0.xsd">

<display-name>Exception Handling</display-name>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>

<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter</filter-class>
Expand All @@ -15,5 +18,5 @@
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>

</web-app>
2 changes: 1 addition & 1 deletion exception-handling/src/main/webapp/error.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<h4>Exception Details: <s:property value="exceptionStack"/></h4>


<p><a href="index.jsp">Return to the home page.</a></p>
<p><a href="<s:url action='index' />">Return to the home page.</a></p>
</body>

</html>
2 changes: 1 addition & 1 deletion exception-handling/src/main/webapp/index.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<s:submit value="Submit"/>
</s:form>

<p><a href="register.jsp">Please register</a> for our prize drawing.</p>
<p><a href='<s:url action="registerForm" />'>Please register</a> for our prize drawing.</p>
<p><a href='<s:url action="causeexception" />'>Cause Exception</a></p>
<p><a href='<s:url action="causenullpointerexception" />'>Cause Null Pointer Exception</a></p>
<p><a href='<s:url action="causesecurityexception" />'>Cause Global Security Exception</a></p>
Expand Down
2 changes: 1 addition & 1 deletion exception-handling/src/main/webapp/login.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

<p>Please login</p>

<p><a href="index.jsp">Return to the home page.</a></p>
<p><a href="<s:url action='index' />">Return to the home page.</a></p>

<hr>

Expand Down
2 changes: 1 addition & 1 deletion exception-handling/src/main/webapp/securityerror.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@
<h4>Exception Name: <s:property value="exception"/></h4>
<h4>Exception Details: <s:property value="exceptionStack"/></h4>

<p><a href="index.jsp">Return to the home page.</a></p>
<p><a href="<s:url action='index' />">Return to the home page.</a></p>
</body>
</html>