Struts help

S

Stefan

I'm very new to struts and am trying to develop a very simple test -
just navitaging to a home page - index.jsp...

I'm running WebLogic 8.1 and Struts 1.1.

Every time I try to navigate to
http://localhost:7001/myWebApp/lookup/home/

I get a page NOT FOUND in the browser and the web server error log
outputs 'SEVERE: Invalid path /home/ was requested.'....

Every time I try to navigate to
http://localhost:7001/myWebApp/lookup/home (without the slash at the
end)

I get a page CANNOT BE DISPLAYED in the browser and the web server
error log outputs
ERROR 13 Nov 2003 12:18:12,726 nulljava.lang.NullPointerException
ERROR 13 Nov 2003 12:18:12,726 nulljava.lang.NullPointerException
ERROR 13 Nov 2003 12:18:12,726 nulljava.lang.NullPointerException


Any idea of what i'm doing wrong:

Thanks!!

index.jsp simply contains one line:
<jsp:forward page="/lookup/home/" />

web.xml contains:

<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>
<init-param>
<param-name>mapping</param-name>
<param-value>org.grnds.structural.ic.struts.IcActionMapping</param-value>
</init-param>
<init-param>
<param-name>debug</param-name>
<param-value>3</param-value>
</init-param>
<init-param>
<param-name>detail</param-name>
<param-value>3</param-value>
</init-param>
<init-param>
<param-name>validate</param-name>
<param-value>false</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>/lookup/*</url-pattern>
</servlet-mapping>


action-mapping in struts-config:

<action-mappings>
<action path="/home">
<set-property property="implClass"
value="org.grnds.structural.ic.action.SimpleAction" />
<set-property property="navCtrl" value="NAV_CTRL_NONE" />
<forward name="success" path="/index.jsp"/>
</action>
</action-mappings>
 
T

Tim Slattery

Every time I try to navigate to
http://localhost:7001/myWebApp/lookup/home (without the slash at the
end)

I get a page CANNOT BE DISPLAYED in the browser and the web server
error log outputs
ERROR 13 Nov 2003 12:18:12,726 nulljava.lang.NullPointerException
ERROR 13 Nov 2003 12:18:12,726 nulljava.lang.NullPointerException
ERROR 13 Nov 2003 12:18:12,726 nulljava.lang.NullPointerException
 
T

Tim Slattery

web.xml contains:

<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>
<init-param>
<param-name>mapping</param-name>
<param-value>org.grnds.structural.ic.struts.IcActionMapping</param-value>
</init-param>
<init-param>
<param-name>debug</param-name>
<param-value>3</param-value>
</init-param>
<init-param>
<param-name>detail</param-name>
<param-value>3</param-value>
</init-param>
<init-param>
<param-name>validate</param-name>
<param-value>false</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>/lookup/*</url-pattern>
</servlet-mapping>


I don't think that's right. In web.xml you just define the Struts
servlet that handles all requests ending in *.do. It looks like this:

<servlet>
<servlet-name>action</servlet-name>

<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<init-param>
<param-name>application</param-name>
<param-value>gov.bls.idcf.ppi.struts.ppi</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>1</load-on-startup>
</servlet>

<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
action-mapping in struts-config:

<action-mappings>
<action path="/home">
<set-property property="implClass"
value="org.grnds.structural.ic.action.SimpleAction" />
<set-property property="navCtrl" value="NAV_CTRL_NONE" />
<forward name="success" path="/index.jsp"/>
</action>
</action-mappings>

In struts-config.xml you tell Struts what Java class to use for which
*.do action. This snippet:

<action path="/index"
type="gov.bls.idcf.ppi.struts.HomeAction"
name="HomeBean"
scope="request">
<forward name="HomeEmpty" path="/content/HomeEmpty.jsp"
redirect="false"/>
</action>


tells Struts that when it gets a request for index.do, it should
invoke the Java class "gov.bls.idcf.ppi.struts.HomeAction", and it
should use a bean named "HomeBean" (defined elsewhere in
struts-config.xml) for the form that goes with that page. It also
defines a "forward' named "HomeEmpty" that can be used by the Java
class to direct output to a specific JSP page.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,777
Messages
2,569,604
Members
45,218
Latest member
JolieDenha

Latest Threads

Top