aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes HTML links not linking properly Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "HTML links not linking properly" Watch "HTML links not linking properly" New topic
Author

HTML links not linking properly

Michael Raymond Jr.
Ranch Hand

Joined: May 16, 2005
Posts: 178
So this is probably an easy one, but how can I get my link to open and display?

what I got is:

<% out.println(" <a href=\"\\\\computername\\sharethis\\file1.exe\"> click me</a> "); %>

the link shows fine, and it actually works with a EXE file (asks to save or open it), but if i make file1.exe file1.htm it the page doesn't come up, it's just blank. what do i need to do to make an html file work on a link?


Scooby Snacks for everyone...<br /> <br />SCJA, SCJP 1.4
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61064
    
  66

Not a JSP question. Moved.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61064
    
  66

Why are you using a file path rather than a URL?

And why would you use out.println to emit HTML in a JSP?
Michael Raymond Jr.
Ranch Hand

Joined: May 16, 2005
Posts: 178
Originally posted by Bear Bibeault:
Why are you using a file path rather than a URL?

And why would you use out.println to emit HTML in a JSP?



q1) because you can in html, so why not? it's not a public site, only local.
q2) are you kidding?

this isn't an html issue, i don't think. the links work fine in html, just not when inserted into jsp tags AND when it's an html or other non-executable file. the links do work, just when you click .html files they don't display the content. i assume this must be a beginners question for jsp???


really the question would be whether or not it's possible to do what i'm trying to do with jsp.
[ October 15, 2007: Message edited by: Michael Raymond Jr. ]
Michael Raymond Jr.
Ranch Hand

Joined: May 16, 2005
Posts: 178
<% out.println(" <a href=\"index.html\"> clickme </a> "); %>

I should note that when I don't have a the absolute path like above (in same directory as exectuing jsp) html file extensions do work. the example above the index.html file actually displays.

again, absolute path works on .exe extensions, and seems to work on .html, but the difference being that the content of thehtml file is not displayed, the page just goes blank/white...
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61064
    
  66

q1) JSP doesn't do anything but create an HTML page to be sent to the browser. By the time the page hits the browser, all "JSP-ness" is gone.

q2) No, I'm not kidding. Why would you put HTML markup inside a Java string inside Java inside a JSP? The whole point of JSP is the ability to put markup in template text.
Michael Raymond Jr.
Ranch Hand

Joined: May 16, 2005
Posts: 178
Originally posted by Bear Bibeault:
q1) JSP doesn't do anything but create an HTML page to be sent to the browser. By the time the page hits the browser, all "JSP-ness" is gone.

q2) No, I'm not kidding. Why would you put HTML markup inside a Java string inside Java inside a JSP? The whole point of JSP is the ability to put markup in template text.


1) i don't need any jsp-ness, just the html, so it seems q1 is fine, right?

2) all i want is it to print a link. it does, just the link dosn't work for html files that are not in the same directory as the executing jsp file. you've never seen html code in a jsp .out(" "); statement? i got it from the K&B jsp/servlets book to be honest...newbie just starting out.



instead of asking me why i'm wanting to do this, do you know if it can be done? and if you do, can you kindly tell me how or point me in the right direction?

thanks
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61064
    
  66

q1) What's the exact HTML being sent to the browser? Does the path have any syntax errors? Does it really describe the path to the html file? Is the file on the same system as the browser? "Because I can" is rarely a good answer to the question "why are you doing something in an odd fashion?"

q2) It's a typical newbie mistake. Why use:


when you can use

?
[ October 15, 2007: Message edited by: Bear Bibeault ]
Michael Raymond Jr.
Ranch Hand

Joined: May 16, 2005
Posts: 178


first link: this is what you are suggesting, right? it doesn't do anything different, if yes. just formatted differently.


second link: works...i'm having an issue with formatting absolute path names, not getting sub-files to the JSP working/linking.



i'm just going to use the relative name which works, because i'm not even sure if it's possible to use the absolute name. probably more of a web server issue now that i think about it.


peace
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61064
    
  66

So is the real issue that you are having problems figuring out how to format URLs so that they work in your web apps?
Michael Raymond Jr.
Ranch Hand

Joined: May 16, 2005
Posts: 178
Originally posted by Bear Bibeault:
So is the real issue that you are having problems figuring out how to format URLs so that they work in your web apps?


yeah, i have a servlet that's returning absolute path names to files in a search routine.

i want to print(to the screen) the names of those files (can do), and use the absolute path name (can't do) instead of the relative (can do) name of the files to the page. essentially i have a search servlet that matches an entered string and prints the matches to the screen...those matches need to be hyperlinks to the files that are matched.


possibly helpful info: i have the matched ABS file names in an ArrayList, but have converted them to type File.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61064
    
  66

That's info that would have been helpful from the get-go. But I'm still not grokking what you are trying to do. How about some concrete data examples from your list?
Michael Raymond Jr.
Ranch Hand

Joined: May 16, 2005
Posts: 178
Originally posted by Bear Bibeault:
That's info that would have been helpful from the get-go. But I'm still not grokking what you are trying to do. How about some concrete data examples from your list?


the only info that is really needed is that i'm making a hyper link out of a file name path.

you enter a string, it does a search, it finds a matching file(s) name, and gives that path name IE: c:\\apache\tomcat\mywebapp\afile.html

now i make a hyper link to that file. this can be done if the JSP is in mywebapp. it just doesn't work if afile.html was in, say, c:\\windowns\afile.html
[ October 16, 2007: Message edited by: Michael Raymond Jr. ]
Michael Raymond Jr.
Ranch Hand

Joined: May 16, 2005
Posts: 178
Originally posted by Michael Raymond Jr.:


the only info that is really needed is that i'm making a hyper link out of a file name path.

you enter a string, it does a search, it finds a matching file(s) name, and gives that path name IE: c:\\apache\tomcat\mywebapp\afile.html

now i make a hyper link to that file. this can be done if the JSP is in mywebapp. it just doesn't work if afile.html was in, say, c:\\windowns\afile.html

[ October 16, 2007: Message edited by: Michael Raymond Jr. ]


cheese and effin' rice!

<% out.println(" <a href=\"\\\\computername\\sharethis\\hello.txt\"> click me</a> ")


i found out this is working, just not in firefox. works fine in IE. unbelievable. the link actually works in FF too, just doesn't display the contents of the file like IE does when clicked. case closed for now...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: HTML links not linking properly