• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Writing Anchor Tag in servlet

 
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Saloon Keeper
Posts: 7582
176
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 56
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Rancher
Posts: 4801
50
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
You're not going crazy. You're going sane in a crazy word. Find comfort in this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic