We help IT Professionals succeed at work.

Netbeans - filepath problem

kgpretty
kgpretty asked
on
Medium Priority
331 Views
Last Modified: 2008-02-01
I need to reference a file from a sub-directory location. The file in the main directory, where the sub-directory is located. How do I accomplish this ? I am using NetBeans IDE 4.1.
Comment
Watch Question

Commented:
Not sure if I've understood what you mean. Also, I have never used NetBeans IDE. What I offer here is the general rules:

(1) If the linking file is in folder X, and the linked file is a subfolder of this X, named Y, the link should be like: <a href="Y/linked.htm">

(2) If the linking file is in folder Y, which is inside folder X, and the linked file is in the folder X, the link should be like: <a href="../linked.htm">

Hope I'm not far from what you need.
Huji

Author

Commented:
Not quite, I don't need anchor links. Let's say you had a web application with a main directory and other folders inside that main directory. If you were inside the folder, how would you reference for example an image in the main directory?

Commented:
Well perhaps this is because I don't understand the meaning of "link" in the world of Netbeans. I will do more research and be back.
Huji

Commented:
>>  how would you reference for example an image in the main directory?
If that is going to be in HTML, again you may use the ../ trick like this: <img src="../file.gif" width="19" height="23" alt="">
However, since I think I may be totally misunderstanding your question, I've asked JSP experts to pay attention to this thread. I recommend you up the points if you can, to attract those experts. ( http://www.experts-exchange.com/Web/Web_Languages/JSP/Q_21798329.html )
Wish I can help
Huji

Author

Commented:
Thanx.. I'll wait for someone to answer..
rrzstudent
CERTIFIED EXPERT

Commented:
Are you using JSP ? Which container ? Tomcat ?
rrzstudent
CERTIFIED EXPERT

Commented:
Ok
Try making file paths relative to your container.    
<img src="<%=request.getContextPath()%>/MyImage.gif"/>  
or if you  are not talking about  links then use  something like  
String filePath = application.getRealPath("/MyImage.gif");  

Author

Commented:
I actually need a file to be included in my jsp page. I tried this:
<%@ include file = "request.getContextPath()/weselldvdsDSNconn.jsp" %>
but I received an error which said: "quote symbol expected."
student
CERTIFIED EXPERT
Commented:
><%@ include file = "request.getContextPath()/weselldvdsDSNconn.jsp" %>
If  weselldvdsDSNconn.jsp  is in your web app's root directory then you could use
<%@ include file = "/weselldvdsDSNconn.jsp" %>

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Author

Commented:
wow.. so simple. Thanks
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.