aspose file tools*
The moose likes Struts and the fly likes Can you help a STRUTS newbie? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Can you help a STRUTS newbie?" Watch "Can you help a STRUTS newbie?" New topic
Author

Can you help a STRUTS newbie?

Giuliano Di Giovanni
Greenhorn

Joined: Feb 03, 2009
Posts: 3
Hi everybody.
I'm senior designer in developing OO application in Java but I'm quite new in developing web applications and using struts. Now I have to become "expert" in few weeks and so I found out some tutorials on the net and trying to apply them.

Now I'm facing the usual problems of beginners, I mean understanding what I have to put where.
I would really appreciate your help, I tried a lot of times in changing the xml files and JSP files but the example (a very trivial one) didn't work.
In the following the error, the directory structure and the xml/jsp files.
I'm using Tomcat 6 and struts 1.3.10
I don't think the problem is in the java files. Ant works fine and the behaviour of the various Action and ActionForm is very trivial.

Thanks in advance for all you can tell me about it.
Regards

*************ERROR*******************


*exception

org.apache.jasper.JasperException: org.apache.jasper.JasperException: Unable to load class for JSP
org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:156)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:329)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

root cause

org.apache.jasper.JasperException: Unable to load class for JSP
org.apache.jasper.JspCompilationContext.load(JspCompilationContext.java:620)
org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:144)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:329)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

root cause

java.lang.ClassNotFoundException: org.apache.jsp.index_jsp
java.net.URLClassLoader$1.run(URLClassLoader.java:200)
java.security.AccessController.doPrivileged(Native Method)
java.net.URLClassLoader.findClass(URLClassLoader.java:188)
org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:134)
org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:66)
org.apache.jasper.JspCompilationContext.load(JspCompilationContext.java:618)
org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:144)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:329)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

************END ERROR*******************

************ Directory Structure ********************

SimpleStruts
|
+-- index.jsp (*)
|
+-- build.xml (*)
|
+-- WEB-INF
|
+-- web.xml (*)
|
+-- struts-config.xml (*)
|
+-- struts-bean.tld (*)
|
+-- struts-nested.tld (*)
|
+-- struts-html.tld (*)
|
+-- struts-logic.tld (*)
|
+-- struts-template.tld (*)
|
+-- app.tld (*)
|
+-- classes
| |
| +-- strutsExampleClasses
| |
| +-- ApplicationResources.properties (*)
| |
| +-- Name.java (*)
| |
| +-- NameForm.java (*)
| |
| +-- SetNameAction.java (*)
|
+-- lib
|
+-- commons-beanutils-1.8.0.jar (*)
|
+-- commons-chain-1.2.jar (*)
|
+-- commons-digester-1.8.jar (*)
|
+-- commons-logging-1.0.4.jar (*)
|
+-- commons-validator-1.3.1.jar (*)
|
+-- jsp-api.jar (*)
|
+-- oro-2.0.8.jar (*)
|
+-- servlet-api.jar (*)
|
+-- struts-core-1.3.10.jar (*)
|
+-- struts-taglib-1.3.10.jar (*)
|
+-- struts-tiles-1.3.10.jar (*)

(*) denotes a file



***********WEB.XML**********************

<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->

<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">

<web-app>

<display-name>SimpleStruts</display-name>

<!-- Action Servlet Configuration -->
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<init-param>
<param-name>application</param-name>
<param-value>
StrutsExample.ApplicationResources</param-value>
</init-param>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
<init-param>
<param-name>debug</param-name>
<param-value>2</param-value>
</init-param>
<init-param>
<param-name>detail</param-name>
<param-value>2</param-value>
</init-param>
<init-param>
<param-name>validate</param-name>
<param-value>true</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>


<!-- Action Servlet Mapping -->
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>


<!-- The Welcome File List -->
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
<welcome-file>index.html</welcome-file>
</welcome-file-list>

<!-- Application Tag Library Descriptor -->
<taglib>
<taglib-uri>/WEB-INF/app.tld</taglib-uri>
<taglib-location>/WEB-INF/app.tld</taglib-location>
</taglib>

<!-- Struts Tag Library Descriptors -->
<taglib>
<taglib-uri>/WEB-INF/struts-bean.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-bean.tld</taglib-location>
</taglib>

<taglib>
<taglib-uri>/WEB-INF/struts-html.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-html.tld</taglib-location>
</taglib>

<taglib>
<taglib-uri>/WEB-INF/struts-logic.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-logic.tld</taglib-location>
</taglib>

<taglib>
<taglib-uri>/WEB-INF/struts-nested.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-nested.tld</taglib-location>
</taglib>

<taglib>
<taglib-uri>/WEB-INF/struts-tiles.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-tiles.tld</taglib-location>
</taglib>


</web-app>

************ STRUTS-CONFIG.XML **********************

<?xml version="1.0" encoding="ISO-8859-1" ?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->

<!DOCTYPE struts-config PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 1.3//EN"
"http://struts.apache.org/dtds/struts-config_1_3.dtd">

<struts-config>

<form-beans>
<form-bean name="nameForm"
type="StrutsExample.NameForm"/>
</form-beans>

<global-forwards>
<forward name="success" path="/index.jsp"/>
</global-forwards>

<action-mappings>

<!-- Save user registration -->
<action path="/setName"
type="StrutsExample.SetNameAction"
name="nameForm"
scope="request"
input="/index.jsp"/>
</action-mappings>

</struts-config>



************ INDEX.JSP ********************

<%@ page language="java" %>
<%@ taglib uri="/WEB-INF/app.tld" prefix="app" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/struts-nested.tld" prefix="nested" %>
<%@ taglib uri="/WEB-INF/struts-tiles.tld" prefix="tiles" %>

<html:html>
<head>
<title>
<bean:message key="welcome.title"/>
</title>
<html:base/>
</head>
<body>
<html:errors/>
<html:form action="/setName">
<html:hidden property="action"/>
<bean:message key="prompt.name"/>
<html:text property="name" size="16" maxlength="16"/>
<br></br>
<html:submit>
<bean:message key="button.save"/>
</html:submit>
<html:reset>
<bean:message key="button.reset"/>
</html:reset>
</html:form>
<hr></hr>
<logic:present name="name">
<font color="blue">
<bean:write name="name" property="name"/>
</font>
<hr></hr>
</logic:present>
</body>
</html:html>




Nyanas Kandhan
Ranch Hand

Joined: Jan 27, 2009
Posts: 35
For examples on struts you can refer here. I will suggest you download one example and try executing. In that way you can easily find the problem. All the required jar files can be downloaded with the example. The only thing you need to do is copy and paste the example inside the webapps folder of tomcat.

Struts Examples

regards
Struts Developer


regards,
Nyanaskandhan
Davie Lin
Ranch Hand

Joined: Aug 05, 2007
Posts: 294
I'm using Tomcat 6 and struts 1.3.10
I don't think the problem is in the java files. Ant works fine and the behaviour of the various Action and ActionForm is very trivial.


I am not a expert but I think I know where the problem is
Tomcat 6 have a different version of Servlet than what Struts 1.3.10 is build on
Tomcat 6 use version 2.5 while Struts 1 and 2 both use version 2.4 (hope I am right about this)

Try to use Tomcat 5.5 instead and I think your problem will go away since you don't think there is anything wrong with the code

hope this helps

David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Struts 1 works fine on TC6.

I see Java files, I don't see any class files--but it's hard to tell, because it's really difficult to read with it not being in code tags.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Can you help a STRUTS newbie?