aspose file tools*
The moose likes Servlets and the fly likes Capturing Form Data Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Capturing Form Data" Watch "Capturing Form Data" New topic
Author

Capturing Form Data

Debbie Dawson
Ranch Hand

Joined: Aug 31, 2010
Posts: 30
Not knowing Java...

How do you take input from an HTML form and capture it in Java so you can do something with it?



Debbie

Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61221
    
  66

A servlet deployed in a servlet container.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Debbie Dawson
Ranch Hand

Joined: Aug 31, 2010
Posts: 30
Bear Bibeault wrote:A servlet deployed in a servlet container.


No, I mean how do you physically capture what is typed in each field in an HTML form to a backend Java program.

How does data get from the User browser into variables in your backend Java app?


Debbie

Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61221
    
  66

Yes.

The HTML form is submitted via HTTP to a URL that maps to a Servlet running in a servlet container. The servlet API allows the submitted data to be easily obtained from the HTTP request.
Debbie Dawson
Ranch Hand

Joined: Aug 31, 2010
Posts: 30
Bear Bibeault wrote:Yes.

The HTML form is submitted via HTTP to a URL that maps to a Servlet running in a servlet container. The servlet API allows the submitted data to be easily obtained from the HTTP request.


The data is transferred from the HTML Form via the URL?

Does the data show up in the URL?

Can it be hidden?

Is it safe in the URL from hackers?



Debbie

Wouter Oet
Saloon Keeper

Joined: Oct 25, 2008
Posts: 2700

Debbie Dawson wrote:The data is transferred from the HTML Form via the URL?

That depends on the form method. Get uses the url and post doesn't.

Debbie Dawson wrote:Does the data show up in the URL?

Get: yes; Post: no;

Debbie Dawson wrote:Can it be hidden?

Yes

Debbie Dawson wrote:Is it safe in the URL from hackers?

That depends on the situation. If you're using ssl (https) then yes otherwise no.
That includes the post method.

"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.
Debbie Dawson
Ranch Hand

Joined: Aug 31, 2010
Posts: 30
Wouter Oet wrote:
Debbie Dawson wrote:The data is transferred from the HTML Form via the URL?

That depends on the form method. Get uses the url and post doesn't.


So how is data sent when Post is used?


Debbie Dawson wrote:Does the data show up in the URL?

Get: yes; Post: no;


Again, then how is it sent using Post. Is it magic?


Debbie Dawson wrote:Is it safe in the URL from hackers?

That depends on the situation. If you're using ssl (https) then yes otherwise no.
That includes the post method.


Then shouldn't you be majorly concerned about sending any data via an HTML Form and the URL if people can hack it?


Debbie
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61221
    
  66

Debbie Dawson wrote:Again, then how is it sent using Post. Is it magic?

It's encoded in the body of the request.

Then shouldn't you be majorly concerned about sending any data via an HTML Form and the URL if people can hack it?

Absolutely. Using SSL will keep-safe the data from prying eyes, but the server code can never trust data that it is sent and must always be vigilant for attacks.
pradipta kumar rout
Ranch Hand

Joined: Sep 13, 2010
Posts: 43
to: Debbie Dawson

Please refer a servlet program from any source and your magic is in your hand.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

See RFC 2616 for the HTTP specification: it contains pretty much all you'd ever want to know about the mechanics.

On the server side you don't generally need to think much about the differences between GET and POST, unless you're uploading files, or doing something specific based on the request type.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Capturing Form Data