Re: Where can I find Example

2003-03-07 Thread rasy chet
I can't see anything wrong with your code. If you
want, you can download the source code from the book's
website at www.wiley.com/compbooks/goodwill 

rc
--- Rama [EMAIL PROTECTED] wrote:
 Hi,
 I have been trying to implement Struts for a simple
 applicaiton.
 I am using WLS 6.1 and Struts 1.02. 
 
 
 Application: User enters a stock symbol and clicks
 submit button in the index page.
 if the value is SUNW , it is success and value is
 displayed,
 else it is failure , user is forwarded to starting
 index page.
 
 Here is the following code
 
 
 index.jsp
 
 %@ page language =java %
 %@ taglib uri=/WEB-inf/struts-html.tld
 prefix=html %
 
 html:form action=Lookup name=lookupForm
 type=LookupForm 
 Symbol : html:text property=symbol /
 html:submit /  
 /html:form
 .
 
 
 
 
 LookupAction.java
 import java.io.*;
 import java.util.*;
 import javax.servlet.*;
 import javax.servlet.http.*;
 import org.apache.struts.action.*;
 
 public class  LookupAction extends Action
 {
   protected Double getQuote(String symbol)
   {
   if (symbol.equalsIgnoreCase(SUNW) )
   {
   return new Double(25.00);
 
   }
   return null;
   }
 
   public ActionForward execute(ActionMapping mapping,
   ActionForm form,
   HttpServletRequest request,
   HttpServletResponse response) throws
 ServletException,IOException
   {
   Double price = null;
   // set default target to success
 
   String target = new String(success);
 
   if (form != null)
   {
   // use the LookupFoprm to get request parameters.
 
   LookupForm lookupForm = (LookupForm)form;
 
   String symbol = lookupForm.getSymbol();
 
   price = getQuote(symbol);
 
   }
   // set the target to failure
   if (price == null)
   {
   target = new String(failure);
 
   }
   else
   {
   request.setAttribute(PRICE, price);
   }
 
   // forward to the appropriate view
   return(mapping.findForward(target) );
 
   }
 }
 
 
 
 LookupForm.java
 import java.io.*;
 import java.util.*;
 import javax.servlet.*;
 import javax.servlet.http.*;
 import org.apache.struts.action.ActionForm;
 import org.apache.struts.action.ActionMapping;
 
 public class  LookupForm extends ActionForm
 {
   private String symbol = null;
 
   public String getSymbol()
   { 
   return (symbol);
   }
   public void setSymbol(String symbol)
   {
   this.symbol = symbol;
   }
 
   public void reset(ActionMapping mapping,
 HttpServletRequest request)
   {
   this.symbol=null;
   }
 
 }
 
 
 
 
  struts-config.xml
 ?xml version=1.0 encoding=ISO-8859-1 ?
 !DOCTYPE struts-config PUBLIC -//Apache Software
 Foundation//DTD Struts Configuration 1.0//EN

http://jakarta.apache.org/struts/dtds/struts-config_1_0.dtd;
 struts-config
   
   form-beans
   form-bean name=lookupForm type=LookupForm /
   /form-beans
   action-mappings
   action path=/Lookup type= LookupAction
 name=lookupForm input=/index.jsp
   forward name=success path=/quote.jsp /
   forward name=failure path=/index.jsp /
   /action   
   /action-mappings
 /struts-config
 
 
 
 
 This is the excerpt from web.xml
   taglib
   taglib-uri/WEB-INF/struts-html.tld/taglib-uri
 

taglib-location/WEB-INF/struts-html.tld/taglib-location
   /taglib
 
  servlet
   servlet-nameaction/servlet-name
 

servlet-classorg.apache.struts.action.ActionServlet/servlet-class
   init-param
   param-nameconfig/param-name
   

param-value/WEB-INF/struts-config.xml/param-value
   /init-param
   load-on-startup1/load-on-startup
 /servlet
 
 servlet-mapping
   servlet-nameaction/servlet-name
   url-pattern*.do/url-pattern
 /servlet-mapping
  quote.jsp
 .
 
   Current Price : %= request.getAttribute(PRICE)
 %
   
 ...
 
 
 When I entered the SUNW in the text box, I am
 forwarded to a blank page. 
 I am not seeing any results... why??? 
 
 Please anyone let me know what I am missing?
 Any ideas are really appreciated
 Thanks in Advance
 Rama
 
 
 



__
Do you Yahoo!?
Yahoo! Tax Center - forms, calculators, tips, more
http://taxes.yahoo.com/

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Where can I find Example

2003-03-05 Thread rasy chet
This link has examples from the Oreilly book.
http://examples.oreilly.com/jakarta/

--- Pellier, Marc [EMAIL PROTECTED]
wrote:
 Hi,
 I'm new
 Where can I find exampleS of struts Application
 (other than struts-example) ?
 
 Thanks
 


 Disclaimer: 
 This electronic transmission and any files attached
 to it are strictly 
 confidential and intended solely for the addressee.
 If you are not 
 the intended addressee, you must not disclose, copy
 or take any
 action in reliance of this transmission. If you have
 received this 
 transmission in error, please notify the sender by
 return and delete
 the transmission.  Although the sender endeavors to
 maintain a
 computer virus free network, the sender does not
 warrant that this
 transmission is virus-free and will not be liable
 for any damages 
 resulting from any virus transmitted. 
 Thank You.


 
 

-
 To unsubscribe, e-mail:
 [EMAIL PROTECTED]
 For additional commands, e-mail:
 [EMAIL PROTECTED]
 


__
Do you Yahoo!?
Yahoo! Tax Center - forms, calculators, tips, more
http://taxes.yahoo.com/

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]