Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,151,536 members, 7,812,666 topics. Date: Monday, 29 April 2024 at 05:11 PM

Java Servlet Question - Programming - Nairaland

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

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

(1) (Reply) (Go Down)

Java Servlet Question by bigboyslim(m): 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(m): 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)

Learn 2 Program With Ease / Facebook / I Need Urgent Help On How To Connect VB2010 To Access 2007

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 6
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.