Hi Nic,
Thanks for the reply. My problem is, and maybe I'm over-thinking this
thing, is that my query results are dynamically produced. My result table
looks like this:
Cost Center Minutes Total Cost
606998 34.8 226.20
440500 23.4 152.10
etc...
with the "Cost Center" field being a dynamically-created <A HREF> link to
another servlet which drills down the data to query on all the records
specific to that cost center only. I need a way to pass the value, say
"606998" to a servlet that will query on that value. Since the <HREF> does
not have a specific "value" or "name" field, as does say, a text box, how do
I do this? Remember, I could have up to 100 or more records. How does the
servlet know from the id in your example that that is a parameter name?
Isn't that just text on the screen?
-Steve
-----Original Message-----
From: Nic Ferrier [mailto:[EMAIL PROTECTED]]
Sent: Friday, May 11, 2001 1:03 PM
To: [EMAIL PROTECTED]
Subject: Re: Passing Values to a servlet
>>> "[Steven Shaw]" <[EMAIL PROTECTED]> 11-May-01 6:13:20 PM
>>>
>I have a long list of query results, tabulated. The
>fist column is an <A REF>...</A> format, so that
>I can click on it and produce another query based
>on the value of the [text in the] link.
You mean you have something like this:
<table>
<tr>
<td>id</td>
<td>name</td>
<td>phone</td>
</tr>
<tr>
<td><a href="/query/?id=1">1</a></td>
<td>nic</td>
<td>8238 728 92783</td>
</tr>
>How do I pass the value of the link to a servlet
>that just serves up queries based on that value?
You just ensure that the link points to the servlet mapping.
In the example above the following would be used in your deployment
descriptor:
<servlet>
<servlet-name>query servlet</servlet-name>
<servlet-class>com.nic.QueryServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>query servlet</servlet-name>
<url-pattern>/query/*</url-pattern>
</servlet-mapping>
And the servlet would look like this:
public class QueryServlet
extends HttpServlet
{
public void doGet(...
{
String idStr=request.getParameter("id");
int id=Integer.parseInt(idStr);
//do query on id
.
.
.
PrintWriter out=response.getWriter();
out.println("<table><tr><td>id</td><td>name</td>....
out.println("<tr><td><a
href=\""+request.getServletPath()+"\">"+id+"</a></td>");
.
.
.
}
Ok?
Nic Ferrier
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
This message may contain information which is private, privileged or
confidential and is intended solely for the use of the individual or entity
named in the message. If you are not the intended recipient of this message,
please notify the sender thereof and destroy / delete the message. Neither
the sender nor Sappi Limited (including its subsidiaries and associated
companies) shall incur any liability resulting directly or indirectly from
accessing any of the attached files which may contain a virus or the like.
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html