This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Other Application Frameworks and the fly likes WebWork HelloWorld  Newbie Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Other Application Frameworks
Bookmark "WebWork HelloWorld  Newbie" Watch "WebWork HelloWorld  Newbie" New topic
Author

WebWork HelloWorld Newbie

monika se
Greenhorn

Joined: Mar 23, 2011
Posts: 22
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

Joined: Dec 07, 2010
Posts: 41
Please refer the below link for the sample webwork project

http://www.opensymphony.com/webwork/wikidocs/Basic%20configuration%20and%20your%20first%20action%20-%20Hello%20WebWorld.html

 
 
subject: WebWork HelloWorld Newbie
 
Similar Threads
Parsing error processing resource path /WEB-INF/struts-config.xml
org.apache.jasper.JasperException: java.lang.NullPointerException: Module 'null' not found.
Once more: javax.servlet.jsp.JspException: Cannot find bean
Unable to load tag handler class "com.opensymphony.webwork.views.jsp.PropertyTag
error comes while running the struts application please see the source code for detail