This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Servlets and the fly likes dynamic parameters Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "dynamic parameters" Watch "dynamic parameters" New topic
Author

dynamic parameters

srini kami
Greenhorn

Joined: Dec 29, 2002
Posts: 26
I am working on a project involving 2servlets, I can't figure out how to pass parameters from one servlet to another. I am trying pass parameter value in url.
Follwoing is the code segment

for (int i=0; i<titl.size(); i++) {

out.println("<p>" + "<a href=\"http://localhost:8080/test/servlet/DetlReq?Post_titl=param1\">" +(String)titl.get(i) + "</a>\n");

//titl is ArrayList

}
The code above gets all the values from arraylist amd makes them all into separate links.

In the above code the value of Post_titl(in this case 'param1') is dynamic, it could be any one the values from ArrayList titl.
Is there any API in java to capture value of the link user clicks on so i can pass it as value of Post_titl in the above URL?
If someone can help i will apprecaite it very much.
More info
Its like master/detail kind of process. Just like this forum user posts lot of data and title becomes link and rest goes to database. Once users clicks on link, the value of the link is passed to other servlet to get rest of the info from databse.
Is there any API in java to capture value of the link user clicks on?
[ July 08, 2003: Message edited by: srini kami ]

Thank you<br />Srini
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12760
    
    5

You get the value from the response with
String title = resp.getParameter("Post_titl");
[ July 08, 2003: Message edited by: William Brogden ]
srini kami
Greenhorn

Joined: Dec 29, 2002
Posts: 26
Hi William
Thank you for the response but i think i wasn't clear enough. What i meant was how do i assign value to "Post_titl". So i can get it using String title = resp.getParameter("Post_titl"); just as you said.
The value to be assigned is the link value.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12760
    
    5
I'm not clear on your problem. Whats wrong with assigning the value in the statement that writes the href= link?
Bill
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: dynamic parameters
 
Similar Threads
linking struts2 action to pre-existing pure Java servlet
Redirecting or Forwarding to another Portlet with Params
Passing parameter to servlet from another servlet
Passing parameters
html:link Dynamic data