Re: Application base URL



I actually just tackled a similar problem. But my hosting company
would not allow me to write to my own domain, I had to write to a
generally accessible temp folder.

Just copy and paste this code into a servlet/JSP page and run it. It
should reveal which method you should use.

where...
F = first letter of login name
S = second letter of login name
T = third letter of login name

try{
x = new File("/home/content/F/S/T/FSTloginName/html/temp/1.txt");
filUploadedFile = new File("/tmp/1.txt");
filUploadedFile.createNewFile();
out.println("<br>");
}catch(Exception e){
e.getLocalizedMessage();
out.println("<br><br>");
out.println(e.getLocalizedMessage());
out.println("<br>" );
}

try{
x = new File(request.getContextPath() + "./" + "f.txt");
x.createNewFile();
out.println("good " + x.getAbsolutePath());
out.println(" x.getAbsolutePath()<br>");
}catch(Exception e){
out.println("<br><br>");
out.println("BAD 1-> request.getContextPath()./<br>");
out.println("<br>" + request.getContextPath());
}
try{
x = new File(request.getContextPath() + "/" + "e.txt");
x.createNewFile();
out.println("good " + request.getContextPath() + "<br>");
out.println(" request.getContextPath(/)<br>");
}catch(Exception e){
out.println("<br><br>");
out.println("BAD 2-> request.getContextPath()/");
out.println("<br>" + request.getContextPath());
}

out.println("<br><br>round 2<br><br>");

try{
x = new File(".", "d.txt");
out.println("good " + x.getAbsolutePath());
out.println(" x.getAbsolutePath()<br>" );
x.createNewFile();
}catch(Exception e){
out.println("<br><br>");
out.println("BAD -> new File(.)");
out.println("<br>" );
}


try{
x = new File(request.getContextPath(), "c.txt");
x.createNewFile();
out.println("good " + x.getAbsolutePath());
out.println(" x.getAbsolutePath()<br>");
}catch(Exception e){
out.println("<br><br>");
out.println("BAD 1-> request.getContextPath()./<br>");
out.println("<br>" + request.getContextPath());
}
try{
x = new File(request.getContextPath(),"b.txt");
x.createNewFile();
out.println("good " + request.getContextPath() + "<br>");
out.println(" request.getContextPath(/)<br>");
}catch(Exception e){
out.println("<br><br>");
out.println("BAD 2-> request.getContextPath()/");
out.println("<br>" + request.getContextPath());
}


good luck!

<a href="www.electricHappiness.com">_</a>

Babu Kalakrishnan wrote:
Andrew Thompson wrote:
zakmck73@xxxxxxxx wrote:
..

Now, how may I know what exactly is "http://some.host.net:port/myApp/";
from whitin a JSP or a servlet?


<http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/servlet/ServletContext.html#getRealPath(java.lang.String)>


That would give you only the RealPath relative to the local file system.
(On my local server, it would return "/opt/tomcat55/webapps/myApp/xxx" )

The original question cannot really be answered in a global context. For
instance, the same resource may be available under several variants of
the URL. e.g. A certain page that may be accessible as
"http://127.0.0.1:8080/myApp/index.jsp"; from my local machine would only
be accessible with a different hostname/IP when the same is accessed
from another machine on the internet.

This information therefore would be relevant only in the context of a
particular HTTP request, and one can obtain it using :

request.getRequestURL();

BK

.



Relevant Pages

  • Re: Application base URL
    ... from whitin a JSP or a servlet? ... That would give you only the RealPath relative to the local file system. ... The original question cannot really be answered in a global context. ... A certain page that may be accessible as "http://127.0.0.1:8080/myApp/index.jsp"; from my local machine would only be accessible with a different hostname/IP when the same is accessed from another machine on the internet. ...
    (comp.lang.java.help)
  • Re: Websites require a login
    ... up until a few days ago, I did not have to log in to a web site ... as if I am not a user on the local machine. ... Just because you're logged into Windows ... That's why the server is requiring a login. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Profile
    ... If the machine was connected tor the domain, you can login also without network connection using the cached credentials on the local machine. ... Is it a standalone server or domain controller? ...
    (microsoft.public.windows.server.general)
  • Re: Slow logon to 2003 domain and DHCP problems
    ... down the DNS server on the Solaris server. ... not find the NIC drivers so I got the XP Home style of login. ... believe the SID refers to that deleted user. ... button, the only location is the local machine, there is NO domain. ...
    (microsoft.public.windows.server.networking)
  • Websites require a login
    ... if I am not a user on the local machine. ... I am using windows authentication, ... authorization is the problem. ... Still requires a login. ...
    (microsoft.public.dotnet.framework.aspnet)