File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes 2 Part Question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "2 Part Question" Watch "2 Part Question" New topic

2 Part Question

Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15302

1. I have a form that requests 2 entries. When I submit this, I also need to send one other value along with the other 2 that the user does not enter, but it will change with each dynamically built HTML page.
2. Can you send values to a servlet through <A HREF> without using a FORM?

GenRocket - Experts at Building Test Data
Dave Vick
Ranch Hand

Joined: May 10, 2001
Posts: 3244
1. Can you use a hidden form field? It is an HTML input field who's type is 'hidden'. when the page is created set its value t wheatever you want it to be and it will be sent with the user inputs to the servlet.
2. If your dynamically building the href you can just append a '?name=value. Onto the end of it and then it is accesible through the request parameters.
hope that's what you're looking for

Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15302

That's perfect Dave. Exactly what I was looking for. Thanks a bunch!
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63852

If you use an <a> tag to invoke the servlet, be sure that you have implemented doGet().

[Asking smart questions] [About Bear] [Books by Bear]
I agree. Here's the link:
subject: 2 Part Question
It's not a secret anymore!