Java Servlet Question - Programming - Nairaland
Nairaland Forum › Science/Technology › Programming › Java Servlet Question (806 Views)
| 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 |
Help On How To Run A Servlet Http Program • 2 • 3 • 4
What Is Programming • Mastermind Series • Programming Platform Advice Needed In Terms Of Most Rewarding