aspose file tools*
The moose likes Servlets and the fly likes Call servlet in a  href tag Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Call servlet in a  href tag" Watch "Call servlet in a  href tag" New topic
Author

Call servlet in a href tag

Deepak Chawla
Ranch Hand

Joined: Nov 19, 2003
Posts: 50
I have this code writtn in JSp, it list me all the files and i want that when i click on these files, it should invoke a servlet which displays the contents of files, the name f the servlet is viewAttachment, i don't how to invoke servet inside a href tag. plz help
<%
int filesdisplay = filenames.length;
for(int i =0;i<filesdisplay;i++)
{
out.write( "<a href='docs/" + filenames[i] + "'>" + filenames[i] + "</a>" );

}


%>
Sri Basavanahally
Ranch Hand

Joined: Oct 07, 2003
Posts: 75
Deepak,
IS Docs your application context or root ? If so, you can say "Docs/servlet/viewAttachment" in your A HREF.
-Sri


UP THE IRONS !
Tim Baker
Ranch Hand

Joined: Oct 04, 2003
Posts: 541
if docs is the context i think you want something like
out.write( "<a href='docs/servlet/viewAttachment?file=" + filenames[i] + "'>" + filenames[i] + "</a>" );


Kim Jong II (North Korea's Dear Leader) said:Nuclear weapons don't kill people, people kill people.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Call servlet in a href tag