17.6. An Applet That Sends POST Data

Listing 17.7 presents an applet that follows the approach outlined in the previous section. The applet uses a URLConnection and an attached ByteArrayOutputStream to send POST data to a URL the user specifies. The applet also makes use of the LabeledTextField class, shown previously in Listing 2.2 and available for download from http://www.coreservlets.com/.

Figures 17-4 and 17-5 show the results of submitting the data to the ShowParameters servlet and EchoServer HTTP server, respectively.

Figure 17-4. Result of using SendPost to send POST data to the ShowParameters servlet, which is presented in Section 3.4 (Example: Reading All Parameters).
Figure 17-5. Result of using SendPost to send POST data to the

Get Core Servlets and JavaServer Pages™ now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.