₦airaland Forum

Welcome, Guest: RegisterLoginWith GoogleTrendingRecentNew

Stats: 3,325,957 members, 8,424,328 topics. Date: Thursday, 11 June 2026 at 02:45 AM

Toggle theme

Java Servlet Question - Programming - Nairaland

Nairaland ForumScience/TechnologyProgrammingJava Servlet Question (806 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 Program234

What Is ProgrammingMastermind SeriesProgramming Platform Advice Needed In Terms Of Most Rewarding