wood burning stoves 2.0*
The moose likes Struts and the fly likes error in output Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "error in output" Watch "error in output" New topic
Author

error in output

sailaja kasanur
Greenhorn

Joined: Dec 18, 2012
Posts: 1

index.jsp:

<%@
page language = "java" contentType = "text/html; charset=ISO-8859-1"
pageEncoding = "ISO-8859-1" %>
<!
DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ taglib prefix = "s" uri = "/struts-tags" %>
<%@ page import = "java.util.*;" %>
<html>
<head >
<title>Pet Store</title>
</head>
<body>
<h1>Pet Store</h1>
<body>
<h2> Dog</h2>
< s:iterator value = "dogList" var = "dog" > < td >< s:property value = "id" /> <s:property value = "type" /></ td > < td >< s:property value = "age" /></ td > < td >< s:property value = "sex" /></ td > < td >< s:property value = "price" /></ td > < td >< input type = "checkbox" value = "select" ></ td > </s:iterator>
Id Type Age Sex Price Select

</body >
</ html >
struts.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 >
< constant name = "struts.enable.DynamicMethodInvocation" value = "false" />
< constant name = "struts.devMode" value = "false" />
< package name = "default" extends = "struts-default" namespace = "/" >
< action name = "display"
class = "com.petstore.view.PetStoreAction" >
< result name = "success" > index.jsp </ result >
</action>
</package>
</struts >

web.xml:
<? xml version = "1.0" encoding = "UTF-8" ?>
<web-app xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance" xmlns = xmlns:web = xsi:schemaLocation = id = "WebApp_ID" version = "2.5" >
<display-name>Struts2 Application</display-name>
<filter>
<filter-name>struts2</filter-name>
<!-- <filter-class>
org.apache.struts2.dispatcher.FilterDispatcher
</filter-class> -->
<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>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list >
</web-app>

PetManger.java:
package com.petstore.controller;
import java.util.List;
import org.hibernate.HibernateException;
import org.hibernate.Session;
import com.petstore.model.Dog;
import com.petstore.util.HibernateUtil;

public class PetManager extends HibernateUtil {
public List<Dog> getDogList() {
Session session = HibernateUtil.getSessionFactory().getCurrentSession();
session.beginTransaction();
List<Dog> dogList = null;
try {
dogList = (List<Dog>)session.createQuery("from Dog").list();
} catch (HibernateException e) {
e.printStackTrace();
session.getTransaction().rollback();
}
session.getTransaction().commit();
return dogList;
}
}
PetStoreAction.java:
package com.petstore.view;
import java.util.List;
import com.opensymphony.xwork2.ActionSupport;
import com.petstore.model.Dog;
import com.petstore.controller.PetManager;
public class PetStoreAction extends ActionSupport {
private Dog dog;
private List<Dog> dogList;
private Long id;
private PetManager manager;
public PetStoreAction() {
manager = new PetManager();
}
public String execute() {
this.dogList = manager.getDogList();
return SUCCESS;
}
public String display (){
this.dogList = manager.getDogList();
return SUCCESS;
}
}
Dog.java:

package com.petstore.model;
public class Dog {
privateint id ;
private String type ;
private String sex ;
privatelong price ;
privateint age ;
Dog (){}
publicvoid setId( int i){
this . id =i;
}
publicint getid(){
return id ;
}
publicvoid setType(String dogType){
this . type = dogType;
}
public String getType(){
return type ;
}
publicvoid setSex( String dogSex){
this . sex = dogSex;
}
public String getSex(){
return sex ;
}
publicvoid setPrice( long dogPrice){
this . price = dogPrice;
}
publiclong getPrice(){
return price ;
}
publicvoid setAge( int dogAge){
this . age = dogAge;
}
publicint getAge(){
return age ;
}
}


HibernateUtil.java:

package com.petstore.util;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.AnnotationConfiguration;
public class HibernateUtil {
private static final SessionFactory sessionFactory = buildSessionFactory();
private static SessionFactory buildSessionFactory() {
try {
// Create the SessionFactory from hibernate.cfg.xml
return new AnnotationConfiguration().configure()
.buildSessionFactory();
} catch (Throwable ex) {
System.err.println("Initial SessionFactory creation failed." + ex);
throw new ExceptionInInitializerError(ex);
}
}
public static SessionFactory getSessionFactory() {
return sessionFactory;
}
}





Hi I am new to struts. I am trying to display records from DOG table. But the output displays only web page. No error is shwon.

Any help would be appreciated.

thanks
Sailaja







 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: error in output