|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
SlickEdit: Code in over 40 languages across 7 platforms. SlickEdit’s unmatched power, speed, and flexibility allows even the most accomplished developers to write better code faster. Download a free trial today! |
|
#1
|
|||
|
|||
|
How do I get variables from a form. I read devshed's article but now I am trying to go beyond what they have done and find out how I can get info from a form. Can someone give me a quick explanation or lead me to a place where I could learn how?
|
|
#2
|
|||
|
|||
|
In order to get variables from your HTML form in your servlet you need to access the HTTPRequest object in your doGet or doPost method. I am assuming that you have some code like this:
public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException{...} In order to get the values that were entered into the form you need to use code like this in your doGet or doPost method: String phone = req.getParameter("phoneNumber"); You will probably have different parameters, but you will just need to enter their names where I have used "phoneNumber". The name you pass to the getParameter() method needs to be the name you gave the field in your HTML form. A good tutorial can be found at: http://developer.java.sun.com/devel...troduction.html I hope that helps.
__________________
- MW |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Java Help > How to get variables from a form? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|