This week's book giveaway is in the Java in General forum.
We're giving away four copies of Event Streams in Action and have Alexander Dean & Valentin Crettaz on-line!
See this thread for details.
Win a copy of Event Streams in Action this week in the Java in General forum!

kathir vel

Ranch Hand
+ Follow
since Jul 03, 2007
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by kathir vel

OK.Html Taglib is for struts.SQL and XML taglibs is for JSTL in JSP.Thanks for your replies.
Sorry for the new posts.I thought you won't notice my post replies.

I got it.I got an error in validate method.Now It works.I thank you for your patience and help.
I think,HFSJ didn't cover Html taglib and SQLtaglib.Where can I refer to study those taglibs?
Hi Marc and Christophe,
I just included <html:errors/> in form.jsp.Is it enough to see the errors?
I tried your code in form.It was working first.But second time just I opened that page.Again it is showing the same problem.

my result.jsp

%@ page import="java.util.*" %>

<html>
<head>
<title>My Beer Choice</title>
</head>
<body>
<h1>Beer Recommendations JSP</h1><br>
<%
List styles=(List)request.getAttribute("styles");
Iterator it=styles.iterator();
while(it.hasNext())
{
out.println("<br>try :"+it.next());
}
%>
</body>
</html>
I tried it.Still it is not working.In address box it is showing the SelectBeer.do after submit.But it is not showing result.jsp.It is same as form.jsp.
Hi All,
I tried the struts_beer sample program,exactly the same way in the book page740.But it is not forwarding the request from form.jsp to servlet.In the address bar it is changing as SelectBeer.do,but it is showing the same form.jsp.Can anyone help how to debug about forwarding in this program?



package com.example.web;

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 javax.servlet.http.*;

public class BeerSelectionForm extends ActionForm
{
private String color;
public void setColor(String color)
{
this.color=color;
}
public String getColor()
{
return color;
}
private static final String VALID_COLORS="amber,dark,brown,light";
public ActionErrors validate( ActionMapping mapping,HttpServletRequest request)
{
ActionErrors errors=new ActionErrors();
if(VALID_COLORS.indexOf(color)== -1)
{
errors.add("color", new ActionMessage("error.colorField.notValid"));
}
return errors;
}
}


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");

}

}



<?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>



<?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.jsp">
<forward name="show_results" path="/result.jsp" />

</action>

</action-mappings>



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

</struts-config>
Hi All,
I tried the struts_beer sample program,exactly the same way in the book page740.But it is not forwarding the request from form.jsp to servlet.In the address bar it is changing as SelectBeer.do,but it is showing the same form.jsp.Can anyone help how to debug about forwarding in this program?Advance Thanks.
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");

}

}
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?
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.
Yes.I copied struts-core-1.3.8.jar in WEB-INF\lib folder.
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?
Hi All,
I installed struts1.3.8.My BeerSelectionForm.java is not compiling.It couldn't find ActionError class.I included struts-core-1.3.8.jar.What jar file should I include on compilation?Thanks.
Hi All,
I am new to struts.Can anyone tell me in lib folder which jar has ActionError class?My java code is not compiling bcoz of that class.
11 years ago
Hi All,
When I am installing Struts1.3.8 framework,I couldn't find struts.jar file inside lib folder.I need struts.bar to compile my components.CAn any one tell me is there any equalent jar file inside lib folder?Thanks.
11 years ago