₦airaland Forum

Welcome, Guest: Register • Login • With Google • Trending • Recent • New

Stats: 3,344,352 members, 8,511,458 topics. Date: Sunday, 01 November 2026 at 05:19 PM

Toggle theme

Java Servlet Question - Programming - Nairaland

Nairaland Forum › Science/Technology › Programming › Java Servlet Question (824 Views)

1 Reply (Go Down)

Java Servlet Question by bigboyslim(op): 7:37pm On Jun 01, 2010
I click on a link in an HTML form,

How can I read in my Servlet code that I clicked on that link.

I'm guessing I would have to use the HttpRequest object.

Thanks
Re: Java Servlet Question by candylips(m): 10:39am On Jun 02, 2010
implement doPost() in the servlet and in your html page have the form implement action="post"
Re: Java Servlet Question by logica(m): 1:12pm On Jun 02, 2010
"doGet" will be more appropriate since it's a link (and I'm assuming the link is not to execute a form submit through Javascript). The link should of course conform to the URL pattern defined for the servlet. And yes, the HttpServletRequest parameter passed to the "doGet" method will allow you to access any parameters you passed through the URL query string.
Re: Java Servlet Question by candylips(m): 1:42pm On Jun 02, 2010
true i forget he was talking about a link
Re: Java Servlet Question by bigboyslim(op): 4:02pm On Jun 02, 2010
Logica and Candylips,

You guys are awesome.

Thanks very much.

What i didn't know before was how to pass parameters through the URL. I have only used submit buttons to send form parameters in the past. The URL query string sounds like a good approach.
Re: Java Servlet Question by candylips(m): 4:33pm On Jun 02, 2010
yes query string is a very neat way of passing parameters easily
1 Reply

Help On How To Run A Servlet Http Program • 2 • 3 • 4

Lets Discuss On "oracle" • Opera Editor Pls Help • Why We Don't Include Main() In Namespace Definition?