rendered paste body<security-constraint>
<web-resource-collection>
<web-resource-name>Employee Area</web-resource-name>
<url-pattern>/AddItem.jsp</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>manager</role-name>
<role-name>employee</role-name>
</auth-constraint>
</security-constraint>
<security-constraint>
<web-resource-collection>
<web-resource-name>Manager Area</web-resource-name>
<url-pattern>/displayItems.do</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>manager</role-name>
</auth-constraint>
</security-constraint>
<security-constraint>
<web-resource-collection>
<web-resource-name>Customer Area</web-resource-name>
<url-pattern>/PaymentInfo.jsp</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>customer</role-name>
</auth-constraint>
<user-data-constraint>
<transport-guarantee>CONFIDENTIAL</transport-guarantee>
</user-data-constraint>
</security-constraint>
<login-config>
<auth-method>BASIC</auth-method>
<realm-name>Lab2ShoppingCart</realm-name>
</login-config>
<security-role>
<role-name>manager</role-name>
</security-role>
<security-role>
<role-name>employee</role-name>
</security-role>
<security-role>
<role-name>customer</role-name>
</security-role>
</web-app>
------------
<hibernate-mapping>
<class name="beans.ItemFormBean" table="item">
<id name="itemId" column="itemId">
<generator class="native"/>
</id>
<property name="itemDescription" column="itemDescription"/>
<property name="itemPrice" type="double" column="itemPrice"/>
<property name="itemQuantity" type="int" column="itemQuantity"/>
</class>
----------------
package managers;
import managers.HibernateUtil;
import java.util.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.hibernate.Session;
import org.apache.struts.action.*;
import beans.*;
public class ItemManager
{
public void addItem (ItemFormBean theBean ) throws Exception
{
Session session = HibernateUtil.getSessionFactory().getCurrentSession();
session.beginTransaction();
session.save(theBean);
session.getTransaction().commit();
HibernateUtil.getSessionFactory().close();
}
public ArrayList get () throws Exception
{
Session session = HibernateUtil.getSessionFactory().getCurrentSession();
session.beginTransaction();
ArrayList list = (ArrayList)session.createQuery("from ItemFormBean").list();//here from Client --> from the bean
session.getTransaction().commit();
HibernateUtil.getSessionFactory().close();
return list;
}
public void updateItem (ItemFormBean theBean ) throws Exception
{
Session session = HibernateUtil.getSessionFactory().getCurrentSession();
session.beginTransaction();
session.update(theBean);
session.getTransaction().commit();
HibernateUtil.getSessionFactory().close();
}
public ItemFormBean getById (int itemId) throws Exception
{
Session session = HibernateUtil.getSessionFactory().getCurrentSession();
session.beginTransaction();
ItemFormBean anItem = (ItemFormBean)session.get(ItemFormBean.class,itemId);
session.getTransaction().commit();
HibernateUtil.getSessionFactory().close();
return anItem;
}
}
-----------
general.title=Generated from the Application resource file.
addItem.title=<h2>Add an Item</h2>
error.itemDescription=<font color = "#990000">Please enter an Item Description</font>
error.itemPrice=<font color = "#990000">Please enter a Price >= 0</font>
error.itemQuantity=<font color = "#990000">Please enter a Quantity > 0</font>
edit.title=<h2>Update an Item</h2>
error.userName=<font color = "#990000">Please enter a user name</font>
error.userPassword=<font color = "#990000">Please enter a user password</font>
error.reEnteredPassword=<font color = "#990000">The reEntered password must match the user password</font>
------------