Win a copy of The Business Blockchain this week in the Cloud forum!
    Bookmark Topic Watch Topic
  • New Topic

HFSJ page 742

 
kathir vel
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
  • Report post to moderator
Hi All,
I tried to do the sample struts application.I have struts 1.3.8.
After submiting the beer type it shows "description The requested resource (Servlet FrontController is not available) is not available".

I had web.xml and struts-config.xml.Can anyone help me?
 
Collins Mbianda
Ranch Hand
Posts: 259
  • Mark post as helpful
  • send pies
  • Report post to moderator
Hi kathir !!!
Where have you copied the struts' jar ?
In WEB-INF/lib ?
 
kathir vel
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
  • Report post to moderator
Yes.I copied struts-core-1.3.8.jar in WEB-INF\lib folder.
 
Marc Peabody
pie sneak
Sheriff
Posts: 4727
Mac Ruby VI Editor
  • Mark post as helpful
  • send pies
  • Report post to moderator
Check your Tomcat log files.

The message you see in the browser simply means that something didn't get set up right. The logs are usually a tad more specific.

Do you have all of your needed classes compiled in the proper directory structures under the WEB-INF/classes directory?

Did you copy all of the other jars that came with Struts into the WEB-INF/lib?

Did you restart Tomcat?

Can you get another non-Struts servlet to work?
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Report post to moderator
What is FrontController assigned to ? Please show us your web.xml too.
 
kathir vel
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
  • Report post to moderator
Hi guys,
I copied all war files to WEB-INF/lib folder. Now it is working with out errors.But it is not forwarding to result.jsp? I am having the same code that is in HFSJ book page 740-743.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Report post to moderator
I copied all war files to WEB-INF/lib folder

WAR files are not meant to be put under WEB-INF/lib. Did you mean all jar files ?

But it is not forwarding to result.jsp?

What is is doing then ?
 
kathir vel
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
  • Report post to moderator
I am sorry.Yes it is Jar files.

my web.xml :

<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">
<servlet>
<servlet-name>FrontController</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>1</load-on-startup>
</servlet>

<servlet-mapping>
<servlet-name>FrontController</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>

</web-app>



my struts-config.xml

<?xml version="1.0" encoding="ISO-8859-1" ?>

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

<struts-config>

<!-- ========== Form Bean Definitions ============ -->
<form-beans>
<form-bean name="selectBeerForm" type="com.example.web.BeerSelectionForm" />
</form-beans>

<action-mappings>
<action
path="/SelectBeer"
type="com.example.web.BeerSelectionAction"
name="selectBeerForm" scope="request"
validate="true" input="/form.html">
<forward name="show_results" path="/result.jsp"/>

</action>

</action-mappings>



<message-resources parameter="ApplicationResources" null="false" />

</struts-config>

After submitting the beer type, it should forward the request to result.jsp.But still shows the same page.Can you help me?
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Report post to moderator
Can you also show your form.html ? and BeerSelectionAction.java as well ?
[ October 25, 2007: Message edited by: Christophe Verre ]
 
kathir vel
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
  • Report post to moderator
Hi
This is form.html

<html>
<head>
My Beer Details
</head>
<body>
<h1> Beer Selection </h1>
<form method="POST" action="SelectBeer.do" >
Select The Color
<select name="color" size="1">
<option>Brown
<option>Light
<option>Amber
<option>Dark
</select>
<center>
<input type="submit" />
</center>
</form>
</body>
</html>

This my action file

package com.example.web;

import java.util.*;
import com.example.model.*;

import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.*;
import javax.servlet.http.*;

public class BeerSelectionAction extends Action
{
public ActionForward execute(ActionMapping mapping,ActionForm form,
HttpServletRequest request,HttpServletResponse response)
{
BeerSelectionForm myForm=(BeerSelectionForm) form;
BeerExpert be=new BeerExpert();
List result=be.getBrands(myForm.getColor());
request.setAttribute("styles",result);
return mapping.findForward("show_results");

}

}
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Report post to moderator
Closed. Continuing here.
 
    Bookmark Topic Watch Topic
  • New Topic