Wrox Programmer Forums
|
BOOK: Professional Jakarta Struts
This is the forum to discuss the Wrox book Professional Jakarta Struts by James Goodwill, Richard Hightower; ISBN: 9780764544378
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional Jakarta Struts section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 13th, 2006, 03:00 AM
Registered User
 
Join Date: Nov 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default About Struts

in struts,I am Making Action class like this code...

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

public class LookupAction extends Action
    {
            protected Double getQuote(String symbol)
                {
                    if ( symbol.equalsIgnoreCase("Narendra") )
                        {
                            return new Double(25.00);
                        }
                    return null;
                }
                public ActionForward execute(ActionMapping mapping,ActionForm form,
                        HttpServletRequest request,
                        HttpServletResponse response)
                        throws IOException, ServletException
                    {
                            Double price = null;
                            // Default target to success
                            String target = new String("success");
                            if ( form != null )
                                {
                                        // Use the LookupForm to get the 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));
        }
}

But it is not working.but if i will use this code then it is working------

import java.io.IOException;
import java.io.PrintStream;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.*;

public class LookupAction extends Action
{

    public LookupAction()
    {
    }

    protected Double getQuote(String s)
    {
        if(s.equalsIgnoreCase("Narendra"))
            return new Double(25D);
        else
            return null;
    }

    public ActionForward perform(ActionMapping actionmapping, ActionForm actionform, HttpServletRequest httpservletrequest, HttpServletResponse httpservletresponse)
        throws IOException, ServletException
    {
        Object obj = null;
        System.out.println("perform");
        if(actionform != null)
        {
            LookupForm lookupform = (LookupForm)actionform;
            String s = lookupform.getSymbol();
            Double double1 = getQuote(s);
        }
        return actionmapping.findForward("success");
    }
}

means when ever i am passing object like target itcis not working
but when evr i m passing "success" it is working.
why?????????
i am waiting 4 reply.
 Regards,
 Nandu






Similar Threads
Thread Thread Starter Forum Replies Last Post
struts actions package: "struts", other packages? ojasrege Struts 1 July 21st, 2007 06:02 AM
about struts kishore.dyn Struts 4 August 8th, 2006 01:28 AM
How to get upgraded from Struts 1.1 to struts 1.2. rayalujakkaraju@yahoo.com Struts 0 January 3rd, 2006 04:29 AM
Struts... babloo81 Servlets 0 March 15th, 2005 12:00 PM
Need help with struts pkmleo J2EE 1 February 27th, 2005 06:27 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.