• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Call servlet in a href tag

 
Deepak Chawla
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Deepak,
IS Docs your application context or root ? If so, you can say "Docs/servlet/viewAttachment" in your A HREF.
-Sri
 
Tim Baker
Ranch Hand
Posts: 541
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if docs is the context i think you want something like
out.write( "<a href='docs/servlet/viewAttachment?file=" + filenames[i] + "'>" + filenames[i] + "</a>" );
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic