my dog learned polymorphism*
The moose likes Struts and the fly likes HTTP 403, Strut2 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "HTTP 403, Strut2" Watch "HTTP 403, Strut2" New topic
Author

HTTP 403, Strut2

Amador Yranon
Greenhorn

Joined: May 26, 2013
Posts: 1
Hello Ranchers,

I am trying to learn Struts and I am using Budi Kurniawan as my references. However, in chapter 2 alone, I am already stuck and felt I can't go on onward unless I can make this sample program run.

Can any one help me. It was almost the same issue of J. Ellis which he posted in 2009. I tried to follow the suggestions in the post but I am getting this error:

HTTP Status 403 - Access to the requested resource has been denied
--------------------------------------------------------------------------------
type Status report
message Access to the requested resource has been denied
description Access to the specified resource has been forbidden.

I am using eclipse Juno Service Release 2 and using Tomcat 7.0.35

and here is the structure:

Strut2App02a
-Java Resource
- src
app02a (package)
product.java
struts.xml

css (folder)
jsp (folder)
ProductDetails.jsp
ProductForm.jsp


Here is the struts.xml and web.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC "-//APache Software Foundation//DTD Struts Configuration 2.0//EN" "http://struts.apache.org/dtds/struts-2.0.dtd">

<struts>

<!-- Un-comment to disable dynamic method invocation -->
<constant name="struts.enable.DynamicMethodInvoication" value="false"/>


<constant name="struts.devMode" value="true"/>

<package name="app02a" namespace="/" extends="struts-default">

<!-- The Product_input action does not have an action class;
it simply forwards control to the ProductForm.jsp page -->
<action name="Product_input">
<result>jsp/ProductForm.jsp</result>
</action>

<!-- The Product_save action has a non-default action class (app02.Product);
since no method attribute is present in the action declaration,
the execute method in the Product class will be invoked -->
<action name="Product_save" class="app02a.Product">
<result>/jsp/ProductDetails.jsp</result>
</action>

</package>
</struts>


<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>

<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>

<security-constraint>
<web-resource-collection>
<web-resource-name>JSPs</web-resource-name>
<url-pattern>/jsp/*</url-pattern>
</web-resource-collection>
<auth-constraint/>
</security-constraint>

<login-config>
<auth-method>BASIC</auth-method>
</login-config>
</web-app>


JSPs

ProductDetails.jsp
<html>
<head>
<title>Save Product</title>
<style type="text/css">@import url(css/main.css);</style>
</head>
<body>
<div id="global">
<h4>The product has been saved.</h4>
<p>
<h5>Details:</h5>
Product Name: ${productName}<br/>
Description: ${description}<br/>
Price: $${price}
</p>
</div>
</body>
</html>

ProductForm.jsp
<html>
<head>
<title>Add Product Form</title>
<style type="text/css">@import url(css/main.css);</style>
</head>
<body>
<div id="global">
<h3>Add a product</h3>
<form method="post" action="Product_save.action">
<table>
<tr>
<td>Product Name:</td>
<td><input type="text" name="productName"/></td>
</tr>
<tr>
<td>Description:</td>
<td><input type="text" name="description"/></td>
</tr>
<tr>
<td>Price:</td>
<td><input type="text" name="price"/></td>
</tr>
<tr>
<td><input type="reset"/></td>
<td><input type="submit" value="Add Product"/></td>
</tr>
</table>


Product.java
package app02a;

import java.io.Serializable;

public class Product implements Serializable {
private String productName;

private String description;

private String price;

public String getProductName() {
return productName;
}

public void setProductName(String productName) {
this.productName = productName;
}

public String getDescription() {
return description;
}

public void setDescription(String description) {
this.description = description;
}

public String getPrice() {
return price;
}

public void setPrice(String price) {
this.price = price;
}

public String execute() {
return "success";
}
}


Thanks in advance,

Amador
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: HTTP 403, Strut2
 
Similar Threads
Cannot get Struts 2 to Work
Unable to insert values in database
Hpp Status 500
unable to run the file
help me tell solve the following error