Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Writing Anchor Tag in servlet

 
srikanth darbha
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Coderanch,

i just want to write an anchor tag inside a servlet  as below,
where selectedurl="D:\Jbehave\Jbehave-09012016\reports.html";

pw.println("<a href='selectedurl'>"+selectedurl+"</a>");

i am able to get the link but when i click,it is getting redirected to "http://localhost:8080/jbehaveauto/selectedurl" in browser but i just want to access the local file system file,can any one please help me out.
 
Tim Moores
Bartender
Posts: 2954
46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
All URLs start with the protocol, "file:" in this case. See File URI scheme for more information.
 
srikanth darbha
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tim Moores wrote:All URLs start with the protocol, "file:" in this case. See File URI scheme for more information.


Thanks Tim,

but on doing the below also it is not working,
String selectedurl = "D:\Jbehave\Jbehave-09012016\reports.html";


                selectedurl ="file:///"+selectedurl;
pw.println("<a href='selectedurl'>"+selectedurl+"</a>");

it is showing as an hyperlink but when i click it is redirecting to "http://localhost:8080/jbehaveauto/selectedurl" but not to the file system "file:///D:\Jbehave\Jbehave-09012016\reports.html"

Regards,
D.Srikanth
 
Dave Tolls
Ranch Hand
Posts: 1908
14
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you look at the html produced you'll see that it will look like this:

Note the href.
That's the value it uses to determine where to go.

You want to change that and not the text that appears in between the open and close tags.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic