Getting the context path in a jspx

Greetings
i have in a JSP this code
<div id="footerpartners"><img src="<%=request.getContextPath()%>/images/aval.png" width="68" height="26" /><img src="<%=request.getContextPath()%>/images/ath.png" width="79" height="26" /><img src="<%=request.getContextPath()%>/images/ciudad_empresarial.png" width="133" height="26" /><img src="<%=request.getContextPath()%>/images/corficolombiana.png" width="140" height="26" /><img src="<%=request.getContextPath()%>/images/superfinanciera.png" width="181" height="26" /><img src="<%=request.getContextPath()%>/images/verisign.png" width="72" height="26" /></div>
and this JSP is being include in a JSPX, when loading the JSPX in my browser i am getting this error
Error de OracleJSP: oracle.jsp.parse.JavaCodeException:Line 3, oracle.jsp.parse.JspParseTagExpression@190fd9b
Error: Java code in jsp source files is not allowed in ojsp.next mod
i believe it is because of the contextPath request....................how can i get it in a jspx

resolved at Getting context path in a jspx

Similar Messages

  • Get the context path with jspx

    How can I get the context path using jspx?
    with jsp I get using scriptlet
    <%=request.getContextPath()%>but it didn't validate with xhtml
    thanks

    I'm really unfamiliar with JSP Documents and I don't know if nesting the tags would be valid. Why don't you use EL in that case?
    ${pageContext.request.contextPath} will print out the value you need.
    P.S. In case it just prints out as is without being evaluated, take a look at these:
    http://faq.javaranch.com/java/ElOrJstlNotWorkingAsExpected
    http://faq.javaranch.com/java/JstlTagLibDefinitions
    http://faq.javaranch.com/java/SetupJstlForJsp2
    http://faq.javaranch.com/java/ServletsWebXml
    People on the forum help others voluntarily, it's not their job.
    Help them help you.
    Learn how to ask questions first: http://faq.javaranch.com/java/HowToAskQuestionsOnJavaRanch
    (Yes I know it's on JavaRanch but I think it applies everywhere)
    ----------------------------------------------------------------

  • How to get the file path in adf application

    hii all,
    i have a txt file that i am using in my adf application,
    i am passing this txt file through a File Reader, for which i have to mention the file path.
    The file is in web-content and when i am hard coding the complete file path i.e C:/JDeveloper/myApp/ViewController/public_html/log.txt
    the application is working fine when run on integrated weblogic server.
    My requirement is to access this file without giving the static file path, as in case i have to use this application on any other machine..
    for that how to mention the file path-
    i tried using FacesContext to get the context path :-
    FacesContext.getCurrentInstance().getExternalContext().getRequestContextPath();
    which gives me
    \myApp-ViewController-context-root
    after appending public_html\log.txt
    I am using the following path to access the file :-
    \myApp-ViewController-context-root\public_html\log.txt
    again i am getting the java.io.FileNotFoundException
    Does anyone know how to use file from inside the web-content without giving the complete path..???
    Thanks

    Hi,
    If you put your file under public_html folder, you can use this code to access the file:
    For example file is : log.txt
    FacesContext.getCurrentInstance().getExternalContext().getRealPath('/log.txt').toString().trim();
    Thanks.
    - LSR

  • Getting the context and host name during initialization

    I am trying to find a way to get the Context path and the host name during the ContextInitialized event, but without any luck. I think it is very strange that you can not even find the context path or the host name of the application you are running yourself.
    Does anybody have an idea?

    What I mean are the configuration elements which are put in the server.xml
    The BIG problem with the getServletContextName is that this returns the name which is put in the web.xml. But I have a web application which is generic and only some config parameters should be altered. Thats why I need to now in which context I am.
    I think the deployment of web applications is wrong by design. I have to specify deployment information inside the application package which in fact should be presented to the servlet container separately. It's like installing new applications on a computer. It should be possible to create 1 installation file (read a web archive) and then specify the location where you want to install it while deploying it (read specify the host name, context location etc.) Now these two are mixed together which I think is wrong.
    Besides the above problem, I think it is also not correct to let users specify properties while configuring a context (either in the server.xml or the web.xml) and then not having an equivelant in the object model (Read the ServletContext object).
    Morten

  • How to get the physical path of my web app root context ?

    Hi,
    I used this code to initialize my LOG4J logger.
            System.out.println(Version + "Servlet context path : " + sctx .getContextPath());
            String path = sctx .getRealPath("/");
            fullyqualifiedlog4jpath = path + "log4j.xml";
            File locallogxml = new File(fullyqualifiedlog4jpath);
            if (locallogxml.exists()) {
                initialized = true;
                DOMConfigurator.configure(fullyqualifiedlog4jpath);
                log = Logger.getLogger(Log4j.class.getName());
                log.info(Version + "Logger initialized");
            else {
                System.out.println(Version + "Unable to locate the log4j.xml file");
            }It works perfectly when running the application with the embedded Jdev11 WLS.
    When deploying the application on a standalone WLS server the path is not returned ;-( I get a null value.
    Does someone has three lines of code which get the physical path of my web app root context?
    Yves

    Changed the methiod used to access log4j.xml.
            FacesContext ctx = FacesContext.getCurrentInstance();
            ServletContext sctx = (ServletContext) ctx.getExternalContext().getContext();
            String contextPath = sctx.getContextPath();
            HttpServletRequest  hsr = (HttpServletRequest)ctx.getExternalContext().getRequest();
            String host = hsr.getServerName();
            int port = hsr.getServerPort();
            try
              String urlstring = "http://" + host + ":" + port + contextPath + "/faces/log4j.xml";
              DOMConfigurator.configure(new URL(urlstring));
              log = Logger.getLogger(Log4j.class.getName());
    .....using the URL s OK.

  • How to get the Real Path of a file which is accessed  by URL?

    iam using tomcat6.0.
    I have a file xyz.xml at the top of the webapplication HFUSE which i can able to access by URL
    http://localhost:8080/HFUSE/xyz.xml
    My problem is how to get the realpath of the file "xyz.xml" for reading and writing purposes.
    I tried various things but i could not able to successfully solved the problem?
    1) File f = new File("/xyz.xml");
    print(f.getAbsolutePath()) ============== it is not fetching the file @ http://localhost:8080/HFUSE/xyz.xml rather it is creating a file
    at the root of the drive where eclipse is running.
    2) File f = new File("xyz.xml");============> this is also not working , it is creating the file xyz.xml in the eclipse directory ..................
    Can anyone please guide on this problem?

    RevertInIslam wrote:
    If you want your context root(i.e HFUSE)
    use this:
    request.getContextPath() //where request is HttpServletRequest object to get the needful path.
    e.g:
    File f = new File(request.getContextPath()+"/xyz.xml");//it will create the file inside HFUSE.
    Hope this helps.
    Regards
    BWrong. The File constructor expects an absolute filesystem path. The HttpServletRequest#getContextPath() doesn't return the absolute filesystem path, it only returns the relative path from the current context root. Use ServletContext#getRealPath() instead, it returns the absolute filesystem path for the given relative path from the current context root.
    File file = new File(servletContext.getRealPath("/"), "xyz.xml");

  • Finding the context path or docBase in a backing bean - Howto

    How should I go about finding the context path or docBase in a backing bean?
    Is there anyway to get this from glassfish or jsf? GlassFish proudly displayed it on the Application Server > Applications > Web Applications > page. It puts it there with an EL for example:
    ${com.sun.aas.instanceRoot}/applications/j2ee-modules/jsf-witaCan and/or should I try to use it in a backing bean? i.e. can I rely on it to stay defined?
    Or should I make a property which I can set for my backing work?

    Is this what you want?
    FacesContext.getCurrentInstance().getExternalContext().getContext()

  • Have a problem in getting the servlet path

    hi
    i wanna get the complete path to my servlet folder in TomcatServer
    like http://localhost:8084/Test can anyone tell me how can i get it plz.

    try ServletContext.getRealPath
    Returns a String containing the real path for a given virtual path. For example, the path "/index.html" returns the absolute file path on the server's filesystem would be served by a request for "http://host/contextPath/index.html", where contextPath is the context path of this ServletContext.
    The real path returned will be in a form appropriate to the computer and operating system on which the servlet container is running, including the proper path separators. This method returns null if the servlet container cannot translate the virtual path to a real path for any reason (such as when the content is being made available from a .war archive).

  • After changing the context path, felix console, I can not checkout content via vlt.

    Hi everyone,
    I have the following issue. After changing the context path, via felix console, I can not checkout the content via vlt. Before that, I could checkout without any problems.
    I am using CQ5.5, CRX2.3, context path: /Test
    That is what I am trying:
    vlt -v --credentials admin:admin co http://localhost:23310/Test/server/crx.default
    Connecting via JCR remoting to http://localhost:23310/Test/server
    [WARN ] Authentication required to access repository descriptors
    [ERROR] checkout: com.day.jcr.vault.vlt.VltException: Unable to mount filesystem
    caused by: javax.jcr.ItemNotFoundException: Not Found
    caused by: org.apache.jackrabbit.webdav.DavException: Not Found
    Other versions I tried:
    vlt -v --credentials admin:admin co http://localhost:23310/crx
    vlt --credentials admin:admin co http://localhost:23310/Test/server
    vlt --credentials admin:admin co http://localhost:23310/Test
    vlt --credentials admin:admin co http://localhost:23310/Test/crx
    To verify if I could connect to the instance properly I started CRXDE
    and try to connect to "http://localhost:23310/Test"
    After click the ok button I got that error:
    No file system is defined for scheme: jcr
    Part of the .log file (.crxde):
    eclipse.buildId=unknown
    java.version=1.6.0_37
    java.vendor=Apple Inc.
    BootLoader constants: OS=macosx, ARCH=x86_64, WS=cocoa, NL=de_DE
    Framework arguments:  -keyring /Users/peterwimsey/.eclipse_keyring -showlocation
    Command-line arguments:  -os macosx -ws cocoa -arch x86_64 -keyring /Users/peterwimsey/.eclipse_keyr
    ing -showlocation
    !ENTRY org.eclipse.core.resources 2 10035 2012-11-25 19:01:19.268
    !MESSAGE The workspace exited with unsaved changes in the previous session; refreshing workspace to
    recover changes.
    !ENTRY org.eclipse.osgi 4 0 2012-11-25 19:04:14.363
    !MESSAGE Application error
    !STACK 1
    java.lang.reflect.InvocationTargetException
            at org.eclipse.ui.actions.WorkspaceModifyOperation.run(WorkspaceModifyOperation.java:121)
            at com.day.cq.ide.CQDEApplication.start(CQDEApplication.java:62)
            at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:194)
            at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLau
    ncher.java:110)
            at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.jav
    a:79)
            at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:368)
            at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
            at java.lang.reflect.Method.invoke(Method.java:597)
            at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:559)
            at org.eclipse.equinox.launcher.Main.basicRun(Main.java:514)
            at org.eclipse.equinox.launcher.Main.run(Main.java:1311)
    Caused by: org.eclipse.core.runtime.CoreException: No file system is defined for scheme: jcr
            at org.eclipse.core.internal.filesystem.Policy.error(Policy.java:55)
            at org.eclipse.core.internal.filesystem.Policy.error(Policy.java:50)
            at org.eclipse.core.internal.filesystem.InternalFileSystemCore.getFileSystem(InternalFileSys temCore.java:65)
            at org.eclipse.core.internal.filesystem.InternalFileSystemCore.getStore(InternalFileSystemCo re.java:107)
            at org.eclipse.core.filesystem.EFS.getStore(EFS.java:350)
            at com.day.cq.ide.fs.JCRFileSystemPlugin.registerExtensions(JCRFileSystemPlugin.java:100)
            at com.day.cq.ide.init.SetupWorkspaceOperation.initWorkspace(SetupWorkspaceOperation.java:16 6)
    Any tips or hints are welcome.
    In the case you need more information, just leave a note.
    Thanks in advance for your help.
    Best regards,
    Peter

    The VLT works fine with the above URL change but How to fix "CRXDE" Initialization error if a context path is defined?
    I have a context path defined /Test and when I am trying to login to CRXDE with URL as http://localhost:4502/Test, I am getting below Initialization Error.
    Any workaround as Which URL should work while logging to repository (with context path) using CRXDE 1.0.1
    eclipse.buildId=unknown java.version=1.6.0_06 java.vendor=Sun Microsystems Inc. BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=en_US Command-line arguments:  -os win32 -ws win32 -arch x86 !ENTRY org.eclipse.osgi 4 0 2013-04-25 17:50:23.802 !MESSAGE Application error !STACK 1 java.lang.reflect.InvocationTargetException at org.eclipse.ui.actions.WorkspaceModifyOperation.run(WorkspaceModifyOperation.java:121) at com.day.cq.ide.CQDEApplication.start(CQDEApplication.java:62) at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:194) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLau ncher.java:110) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.jav a:79) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:368) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:559) at org.eclipse.equinox.launcher.Main.basicRun(Main.java:514) at org.eclipse.equinox.launcher.Main.run(Main.java:1311)
    Caused by: org.eclipse.core.runtime.CoreException: No file system is defined for scheme: jcr
    at org.eclipse.core.internal.filesystem.Policy.error(Policy.java:55) at org.eclipse.core.internal.filesystem.Policy.error(Policy.java:50) at org.eclipse.core.internal.filesystem.InternalFileSystemCore.getFileSystem(InternalFileSys temCore.java:65) at org.eclipse.core.internal.filesystem.InternalFileSystemCore.getStore(InternalFileSystemCo re.java:107) at org.eclipse.core.filesystem.EFS.getStore(EFS.java:350) at com.day.cq.ide.fs.JCRFileSystemPlugin.registerExtensions(JCRFileSystemPlugin.java:100) at com.day.cq.ide.init.SetupWorkspaceOperation.initWorkspace(SetupWorkspaceOperation.java:16 6) at com.day.cq.ide.init.SetupWorkspaceOperation.execute(SetupWorkspaceOperation.java:119) at org.eclipse.ui.actions.WorkspaceModifyOperation$1.run(WorkspaceModifyOperation.java:106) at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1800) at org.eclipse.ui.actions.WorkspaceModifyOperation.run(WorkspaceModifyOperation.java:118) ... 13 more Root exception:
    Thanks.

  • How can I get the context-parm from a web.xml file using struts?

    Hello:
    I need get the context-param from the web.xml file of my web project using struts. I want configurate the jdbc datasource connection pooling here. For example:
    <context-param>
    <param-name>datasource</param-name>
    <param-value>jdbc/formacion</param-value>
    <description>Jdbc datasource</description>
    </context-param>
    and then from any Action class get this parameter.
    Similar using a simple server can be:
    /** Initiates new XServlet */
    public void init(ServletConfig config) throws ServletException {
              for (Enumeration e = config.getInitParameterNames(); e.hasMoreElements();) {
                   System.out.println(e.nextElement());
              super.init(config);
              String str = config.getInitParameter("datasource");
              System.out.println(str);
         public void doPost(HttpServletRequest req, HttpServletResponse res)
              throws ServletException, IOException {
              // res.setContentType( );
              System.out.println("Got post request in XServlet");
              PrintWriter out = res.getWriter();
              out.println("nada");
              out.flush();
              out.close();
    but only this works for init-params, if I use
    <servlet>
         <servlet-name>MyServlet</servlet-name>
         <display-name>MyServlet</display-name>
         <servlet-class>myExamples.servlet.MyServlet</servlet-class>
         <init-param>
         <param-name>datasource</param-name>
         <param-value>jdbc/formacion</param-value>
    </init-param>
    </servlet>
    inside my web.xml. I need something similar, but using struts inside the action class for that I can get the context-params and call my database.
    Thank you

    To get context parameters from your web.xml file you can simply get the ActionServlet object from an implementing action object class. In the perform (or execute) method make the following call.
    ServletContext context = getServlet().getServletContext();
    String tempContextVar =
    context.getInitParameter("<your context param >");

  • How to get the current path of my application in java ?

    how to get the current path of my application in java ?
    thanks

    To get the path where your application has been installed you have to do the following:
    have a class called "what_ever" in the folder.
    then you do a litte:
    String path=
    what_ever.class.getRessource("what_ever.class").toString()
    That get you a string like:
    file:/C:/Program Files/Cool_program/what_ever.class
    Then you process the result a little to remove anything you don't want:
    path=path.substring(path.indexOf('/')+1),path.lastIndexOf('/'))
    //Might be a little error here but you should find out //quickly if it's the case
    And here you go, you have a nice
    C:/Program Files/Cool_program
    which is the path to your application.
    Hooray

  • How can i get the local path to my cached app in jws

    Hi,
    sorry, i think it is a stupid question of me. but i'm a newbie in java and jws...
    So my question is...
    is it possible to get the absolute path to my downloaded an d cached jarfile? (e.g. c:\program files\java web start\.javaws\cache\http\Dmy.server.com\P80\RMmyapp.jar)
    thanks a lot for any help.

    I just answered this elsewhere, but here it is again.
    This code seems to work. I found it last year in one of the forums.
    I use it to find resources in Jars or to find images when I am in an IDE
    The "SetIcon.class" below should be changed to the class you are running from.
    Note: If you are running a class in a package, this returns the root of your application instead of the "folder" containing your package. This would mean that the "images" folder I refer to below is under the root folder, not the package folder.
    javax.swing.ImageIcon img;
    URL imgPath1;
    String imgPath2;
    imgPath1 = SetIcon.class.getProtectionDomain().getCodeSource().getLocation();
    imgPath2 = imgPath1.toString();
    imgPath2 = imgPath2.substring(6); // strip off the "file:"
    imgPath2 = imgPath2 + "images/sample.gif";
    Hope this helps,
    Hale

  • How to get the output path in Java?

    Hi all,
    is there a way (method) to get the output path (where compiled classes are put) in Java?
    thx a lot!
    Michele

    If you have already successfully loaded the classes into memory, and you want to find out where the classes are physically stored, then you can use Class.getResource() to retrieve the location of the file.
    import java.net.URL;
    public class Find
      private void run(String obj) {
        try {             
          Class cls = Class.forName(obj);
          //Here is the change to input correct resource path
          //instead of class name 
          String resourcePath = "/"+obj.replace('.','/')+".class";
          URL url = cls.getResource(resourcePath);
          System.out.println(url);
        catch (Exception e) {
          e.printStackTrace();
      public static void main(String[] args) {
        Find find = new Find();
        find.run(args[0]);   
    }java Find java.lang.String
    jar:file:/usr/local/j2sdk1.4.2_13/jre/lib/rt.jar!/java/lang/String.class
    Edited by: Jin on Oct 23, 2007 10:38 AM

  • When installing or uninstalling iTunes I get 'The folder path 'My Music' contains an invalid character' and fails

    When installing or uninstalling iTunes I get 'The folder path 'My Music' contains an invalid character' and fails

    Download the Windows Installer CleanUp utility from the following page (use one of the links under the "DOWNLOAD LOCATIONS" thingy on the Major Geeks page):
    http://majorgeeks.com/download.php?det=4459
    To install the utility, doubleclick the msicuu2.exe file you downloaded.
    Now run the utility ("Start > All Programs > Windows Install Clean Up"). In the list of programs that appears in CleanUp, select any iTunes entries and click "Remove", as per the following screenshot:
    Quit out of CleanUp, restart the PC and try another iTunes install. Does it go through properly this time?

  • How to get the full path of the fmx's directory.

    Hi all,
    I will ship my project to a customer. So I must install forms runtime at the customer's machine.
    I put all of the fmx files of my project into a certain directory at the customer's machine, and I create a desktop shortcut of the forms runtime. In the "start in" field of the shortcut property I put the full path of the directory where I put the fmx files. And in the target field of the shortcut property I put after the ifrun60.exe the name of the fmx file which to call first.
    Now , in one of my forms file I want to get the full path of this directory because I must call Ora_Ffi.Load_Library. And the library which I want to load resides on that directory.
    So how to get programatically the directory where the fmx files reside.
    I know that there is the registry entry FORMS60_PATH, but we plan to ship many projects to that customer; so if I use the FORMS60_PATH variable then there will be an error because there will be many directories. And the customer can launch many of the projects at the same time.
    So how to get it.
    Thank you very much indeed.

    If you are using the d2kwutil library, then you can use the win_api_environment.Get_Working_Directory() function.
    If not, I doubt that there is anyway to get it since the get_application_property(current_form) does not return the full path of the form as it used to in prior versions of Oracle forms such as 4.5.

Maybe you are looking for

  • 1.2 bios flash works fine on P35 Platinum but still having DMA/PIO trouble on XP

    After all the scare stories of the latest bios I thought I should mention that it worked like a charm for me.  I went from default 1.0D to 1.2 using the MSI Forum HQ USB flashing tool: https://forum-en.msi.com/index.php?topic=108079.0 not using any w

  • Dev and Prod Environment Sync.

    Hello Experts, I would like to ask for your kind help in the following matter:  How to resynch the dev and production environments. For some (inextricable) reason, the production and development servers are out of sync.  Mainly the SLD content is in

  • Photos too big for Flash, what can I do?

    Hi, I have tried all the different Formats of Photo and bringing them into Flash, but they are still too big, causing Flash to crash and meaning I am unable to upload my website to my server. I think i remember being told you could use a preloader. B

  • New Zen MicroPhoto not seen by XP or Vi

    I'm a total newbie to Creative MP3 players. Just got one yesterday from Electronica Direct via Amazon's store. Running Vista on an HP Pavilian dual core (just 3 months old so very new cutting edge hardware) and running XP on a 5 year old Sony Vaio la

  • Unknown software exception (0xc0010000) occurred i...

    help me !!!!! the exeption unknown software exception (0xc0010000) occurred in the application at location 0x77564598 it also starts with like 100mb of ram then 1.5GB of ram help!!!!! some plz tell me how to fix it thx Solved! Go to Solution.