This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

WebWork HelloWorld Newbie

 
monika se
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi I am doing HelloWorld program through webwork.

My HelloWorld.java file is :

package sample;

import com.opensymphony.xwork.ActionSupport;

public class HelloWorld extends ActionSupport {
private String message;

@Override
public String execute() {
message = "Hello, WebWorld!";
return SUCCESS;
}

public String getMessage() {
return message;
}
public void setMessage(String message)
{
this.message = message;
}
}

hello.jsp file is

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="ww" uri="/webwork" %>
<html>
<head>
<title>Hello Page</title>
</head>
<body>
WebWork says:
<h1><ww:property value="message"/></h1>
</body>
</html>

xwork.xml

<!DOCTYPE xwork PUBLIC "-//OpenSymphony Group//XWork 1.0//EN"
"http://www.opensymphony.com/xwork/xwork-1.0.dtd">
<xwork>
<include file="webwork-default.xml"/>
<package name="default" namespace="/" extends="webwork-default">
<default-interceptor-ref name="completeStack"/>

<action name="helloWorld" class="sample.HelloWorld">
<result name="success" type="dispatcher">hello.jsp</result>

</action>

</package>
</xwork>


web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5">
<servlet>
<servlet-name>webwork</servlet-name>
<servlet-class>
com.opensymphony.webwork.dispatcher.ServletDispatcher
</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>webwork</servlet-name>
<url-pattern>*.action</url-pattern>
</servlet-mapping>
<jsp-config>
<taglib>
<taglib-uri>webwork</taglib-uri>
<taglib-location>/WEB-INF/lib/webwork-2.2.7.jar
</taglib-location>
</taglib>
</jsp-config>

<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
</web-app>

webwork.properties
webwork.tag.altSyntax = true



I placed xwork.xml,webwork.properties and package sample inside WEB-INF/classes

and jsp file inside WEB-INF..

After compiling java file and running hello.jsp file, i gets only Webwork says. It does not fetch message and displays it on browser meaning mapping is not tking place ... please help me and tell me possible reasons for this problem.....
 
anirudh jagithyala
Ranch Hand
Posts: 41
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic