Title: RE: Invoking a servlet via a hyperlink

Here are my findings:

If you simply invoke a servlet through a hyperlink and have certain parameters appened to URL then you can only get these parameters through GET METHOD.

    If you want to use POST in the servlet called then write in the GET method something like

            Public void doGet(HttpServletRequest req, HttpServletResponse res) throws.... {

            DoPost(req,res);
    }


If you want the querystring then you will get the complete URL after "?"
You can get querystrings parameters only getParameter

Hope this helps
\




    -----Original Message-----
    From:   Ferghil O'Rourke [SMTP:[EMAIL PROTECTED]]
    Sent:   08 June 2000 07:45
    To:     [EMAIL PROTECTED]
    Subject:        Re: Invoking a servlet via a hyperlink

    I was using req.getParameters() to get the parameter list from
    a normal FORM POST. Work fine. But when from a href getParameters()
    just returns one big flat string.
    A call to getParameter("name") will parse thru the '?' in the href for me?

    Off to try it!
    -F

    -----Original Message-----
    From: A mailing list about Java Server Pages specification and reference
    [mailto:[EMAIL PROTECTED]]On Behalf Of Shrisha Radhakrishna
    Sent: Wednesday, June 07, 2000 7:59 PM
    To: [EMAIL PROTECTED]
    Subject: Re: Invoking a servlet via a hyperlink


    You could use multiple request.getParameter("parameterName") 's to get all
    parameters.

    --Shrisha

    ----- Original Message -----
    From: "Ferghil O'Rourke" <[EMAIL PROTECTED]>
    To: <[EMAIL PROTECTED]>
    Sent: Wednesday, June 07, 2000 6:47 PM
    Subject: Re: Invoking a servlet via a hyperlink


    > Yes. I've just managed to get this working. I can now invoke
    > the servlet and pass in the parm values trailing it.
    >
    > Just a Q since I have you though. When I use req.getParameters()
    > to get the parameter string here it just comes back as one big
    > string. So I'll have to parse the parameters out manually right?
    >
    > Thanks.
    > Ferghil
    >
    > -----Original Message-----
    > From: A mailing list about Java Server Pages specification and reference
    > [mailto:[EMAIL PROTECTED]]On Behalf Of Shrisha Radhakrishna
    > Sent: Wednesday, June 07, 2000 7:37 PM
    > To: [EMAIL PROTECTED]
    > Subject: Re: Invoking a servlet via a hyperlink
    >
    >
    > I might be way off here (since I don't use this approach); but, can't you
    > just say
    >
    > <a
    >
    href="servlet/controllerServlet?name=RetrieveVendors.do&param1=value1..">Hyp
    > erlink</a>
    >
    > This should definitely invoke the controller servlet with all the right
    > parameters.
    >
    > ----- Original Message -----
    > From: "Ferghil O'Rourke" <[EMAIL PROTECTED]>
    > To: <[EMAIL PROTECTED]>
    > Sent: Wednesday, June 07, 2000 5:44 PM
    > Subject: Re: Invoking a servlet via a hyperlink
    >
    >
    > > Yes, I'm pretty sure that I can pass the values via the href ok to the
    > > servlet
    > > and have it parse those parms when it gets them. But that's not the
    > problem.
    > >
    > > The problem is how to get the servlet invoked from the hyperlink. Right
    > now
    > > the hyperlink isn't even invoking my servlet.
    > > Also, I'd prefer not to use javascript if possible as I don't want to
    run
    > > the risk of losing browsers that don't support it.
    > >
    > > -Ferghil
    > >
    > > -----Original Message-----
    > > From: A mailing list about Java Server Pages specification and reference
    > > [mailto:[EMAIL PROTECTED]]On Behalf Of Ian
    > > Sent: Wednesday, June 07, 2000 6:33 PM
    > > To: [EMAIL PROTECTED]
    > > Subject: Re: Invoking a servlet via a hyperlink
    > >
    > >
    > > have you tried using
    > >
    > > <a href="RetrieveVendors.do?name1=value1&name2=value2">my link</a>
    > >
    > > I would think this would pass all the same info as a form.
    > >
    > > /Ian
    > >
    > > -----Original Message-----
    > > From: A mailing list about Java Server Pages specification and reference
    > > [mailto:[EMAIL PROTECTED]]On Behalf Of Ferghil O'Rourke
    > > Sent: Wednesday, June 07, 2000 7:31 PM
    > > To: [EMAIL PROTECTED]
    > > Subject: Invoking a servlet via a hyperlink
    > >
    > >
    > > [sorry, not sure this got submitted earlier...]
    > >
    > > Anyone got any ideas on how handle hyperlinks in an MVC controller
    > servlet?
    > >
    > > We've been in the process of developing a servlet based on the MVC model
    2
    > > architecture for the last few months now. And many thanks to Craig for
    his
    > > key contributions here. I've implemented his action class mechanism
    > > successfully to have a single "controller" servlet interact with java
    > > business objects thru action objects.
    > >
    > > Each action object maps to the name attached to a FORM SUBMIT in our JSP
    > > pages. So, for example, a pushbutton submits the name
    "RetrieveVendors.do"
    > > to the controller servlet, the servlet uses this string as a key to a
    > > hashtable of action class names, instantiates the relevant action class,
    > and
    > > finally invokes it's perform() method. The action class then takes over
    > and
    > > performs processing relavant to that pushbutton. It also has the
    facility
    > to
    > > pull all the data from the SUBMIT into the relevant business object.
    > >
    > > It all works very nicely. However, the whole mechanism does depend on
    all
    > > interaction with the controller servlet being performed using FORM
    > SUBMITS.
    > > I'm fine with this but there are times when I'll want to interact with
    the
    > > controller servlet via a hyperlink - or **via a SUBMIT that looks and
    > > behaves like a hyperlink.**
    > >
    > > SUBMITs will always look like button clicks - the mouse pointer doesn't
    > turn
    > > into a finger but remains as an arrow etc. There are ways to make
    SUBMITs
    > > resemble hyperlinks using IE4 style tags but these don't work for
    > netscape.
    > >
    > > Anyone encountered this sort of problem before? I'd prefer to keep
    > > everything as a SUBMIT so that I'm always routing through the servlet.
    I'd
    > > like to compromise and use a real hyperlink only when the target page
    > > contains static content.
    > >
    > > Any ideas thoughts really welcome.
    > > Thanks,
    > > Ferghil O'Rourke
    > > USMoving.com - chief programmer
    > >
    > >
    >
    ===========================================================================
    > > To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
    > > JSP-INTEREST".
    > > Some relevant FAQs on JSP/Servlets can be found at:
    > >
    > >  http://java.sun.com/products/jsp/faq.html
    > >  http://www.esperanto.org.nz/jsp/jspfaq.html
    > >  http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
    > >  http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
    > >
    > >
    >
    ===========================================================================
    > > To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
    > > JSP-INTEREST".
    > > Some relevant FAQs on JSP/Servlets can be found at:
    > >
    > >  http://java.sun.com/products/jsp/faq.html
    > >  http://www.esperanto.org.nz/jsp/jspfaq.html
    > >  http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
    > >  http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
    > >
    > >
    >
    ===========================================================================
    > > To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
    > JSP-INTEREST".
    > > Some relevant FAQs on JSP/Servlets can be found at:
    > >
    > >  http://java.sun.com/products/jsp/faq.html
    > >  http://www.esperanto.org.nz/jsp/jspfaq.html
    > >  http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
    > >  http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
    >
    >
    > __________________________________________________
    > Do You Yahoo!?
    > Talk to your friends online with Yahoo! Messenger.
    > http://im.yahoo.com
    >
    >
    ===========================================================================
    > To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
    > JSP-INTEREST".
    > Some relevant FAQs on JSP/Servlets can be found at:
    >
    http://java.sun.com/products/jsp/faq.html
    http://www.esperanto.org.nz/jsp/jspfaq.html
    http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
    http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
    >
    >
    ===========================================================================
    > To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
    JSP-INTEREST".
    > Some relevant FAQs on JSP/Servlets can be found at:
    >
    http://java.sun.com/products/jsp/faq.html
    http://www.esperanto.org.nz/jsp/jspfaq.html
    http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
    http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets


    __________________________________________________
    Do You Yahoo!?
    Talk to your friends online with Yahoo! Messenger.
    http://im.yahoo.com

    ===========================================================================
    To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
    JSP-INTEREST".
    Some relevant FAQs on JSP/Servlets can be found at:

     http://java.sun.com/products/jsp/faq.html
     http://www.esperanto.org.nz/jsp/jspfaq.html
     http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
     http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

    ===========================================================================
    To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
    Some relevant FAQs on JSP/Servlets can be found at:

     http://java.sun.com/products/jsp/faq.html
     http://www.esperanto.org.nz/jsp/jspfaq.html
     http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
     http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

�������������������������o unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST". Some relevant FAQs on JSP/Servlets can be found at: http://java.sun.com/products/jsp/faq.html http://www.esperanto.org.nz/jsp/jspfaq.html http://www.jguru.com/jguru/faq/faqpage.jsp?name

Reply via email to