• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Capturing Form Data

 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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

 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A servlet deployed in a servlet container.
 
Debbie Dawson
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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

 
Bartender
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
to: Debbie Dawson

Please refer a servlet program from any source and your magic is in your hand.
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
We don't have time for this. We've gotta save the moon! Or check this out:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic