Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Capturing Form Data

 
Debbie Dawson
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64708
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A servlet deployed in a servlet container.
 
Debbie Dawson
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64708
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Debbie Dawson
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64708
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
to: Debbie Dawson

Please refer a servlet program from any source and your magic is in your hand.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic