Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old December 13th, 2006, 02:00 AM
Registered User
 
Join Date: Nov 2006
Location: Mumbai, Maharastra, India.
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

Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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 03:29 AM
Struts... babloo81 Servlets 0 March 15th, 2005 11:00 AM
Need help with struts pkmleo J2EE 1 February 27th, 2005 05:27 AM



All times are GMT -4. The time now is 02:24 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.