Tile path Resolution by Servlet ?

Hey guys!
Just stumbled across a small problem.
I'm using struts tiles for showing 2 presentation layers "viewA" and "viewB" in a project "WebProject".
Since both Tiles "viewA" and "viewB" use[b] the same Servlets in the project "WebProject", the servlet needs to know which Tile called it, perform the computation and then go to a subfolder "WebProject/viewA/a/callme.jsp" or "WebProject/viewB/b/callme.jsp".
I was just wondering if someone knows how to achieve this?
I'd really appreciate it if you could tell me the mechanism for storing the path(in the servlet) of the Tile that calls the servlet and how to write it so that the control is passed back to that particular Tile.
Thanks in advance for your help.

Sorry for early posting,
actually problem with the requestdispatchar,
if i use sendredirect then page works fine.
so what is the problem with iws for the requestdispatcher

Similar Messages

  • Get absolute path of a servlet/jsp

    <p>
    I have deployed an application on JBoss. I need to get the absolute path of a servlet. I used following statement to do that.
    getServletContext().getRealPath("");
    but from this i get the following
    C:\jboss-4.0.2\server\default\.\deploy\sdb.ear\sdb.war\employer
    i don't know why there is a dot in between the path which is not correct.
    My application.xml is as follow
    <module>
    <ejb>sdb.jar</ejb>
    </module>
    <module>
    <web>
         <web-uri>sdb.war</web-uri>
         <context-root>/</context-root>
    </web>
    </module>
    Pls help me with this

    kaviratne wrote:
    but from this i get the following
    C:\jboss-4.0.2\server\default\.\deploy\sdb.ear\sdb.war\employer
    i don't know why there is a dot in between the path which is not correct.Me neither, but that dot shouldn't harm. It just means "current directory". Effectively that path is exactly the same as:
    C:\jboss-4.0.2\server\default\deploy\sdb.ear\sdb.war\employerWhich problems are you occurring with this? It might be worth an issuereport at the JBoss site though.

  • Get real path in non servlet class

    Hi,
    I've created a ServletContextListener class that loads a thread at application startup and kills it and application shutdown.
    The thread periodically monitors a specific file. I need to pass a real file path to the thread, but because the thread class is not a servlet, I cannot use the getServletContext().getRealPath("").
    What are my options?

    The ServletContextListener has access to both the ServletContext as well as the Thread.
    So the solution can be to get the path in the listener and pass it as a parameter to the constructor or a setter method of the thread.

  • Problem with a path in a servlet

    hello,
    I have a servlet - jsp pair that I am trying to deploy. This is an example I found online and I am trying it out using Tomcat 4.1 however I keep getting errors and hope someone can tell me what I am missing.
    I have compiled the servlet successfully. When I try to invoke it, I get the following error:
    java.lang.IllegalArgumentException: Path login.jsp does not start with a "/" character
    I know that the problem is in the disp = app.getRequestDispatcher("login.jsp");
    line but not sure how to correct it. I have included the syntax for both servlet and jsp and also the paths where they are located in my tomcat directory
    the servlet is located in the following directory in tomcat:
    c:/tomcat4.1/webapps/root/web-inf/classes/jsp/GuestJsp.class
    Here is the syntax for the GuestJsp.java servlet is:
    package jsp;
    import java.io.*;
    import java.util.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    * GuestJsp is a servlet controlling user
    * interaction with the guest book.
    public class GuestJsp extends HttpServlet {
    * doGet handles GET requests
    public void doGet(HttpServletRequest req,
    HttpServletResponse res)
    throws ServletException, IOException
    // Save the message in the request for login.jsp
    req.setAttribute("message", "Hello, world");
    // get the application object
    ServletContext app = getServletContext();
    // select login.jsp as the template
    RequestDispatcher disp;
    disp = app.getRequestDispatcher("login.jsp");
    // forward the request to the template
    disp.forward(req, res);
    the jsp is located in c:/tomcat4.1/webapps/root/login.jsp
    the syntax for the login.jsp is:
    <%@ page language=javascript %>
    <head>
    <title><%= request.attribute.message %></title>
    </head>
    <body bgcolor='white'>
    <h1><%= request.attribute.message %></h1>
    </body>
    thanks in advance
    java newbie

    Doesn't it seem intuitively obvious from the error message that perhaps you should try "/login.jsp" instead of "login.jsp"?

  • Access network path from within servlet

    I'm trying to copy some files from a network path from within a servlet. I realize that I cannot use drive letter mappings as they are profile specific. Instead I'm trying to use the unc path. I'm getting the following error when I read the error inputstream from the process:
    String cmd = "XCOPY \\SERVER\SHARE\File.DAT C:\FOLDER /Y"
    Runtime rt = Runtime.getRuntime();
    Process p = rt.exec(cmd);
    p.waitFor(); //execute process and wait for it to finish
    BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));
    BufferedReader error = new BufferedReader(new InputStreamReader(p.getErrorStream());0 File(s) copied
    Invalid drive specification
    Exit code: 4
    It works from the command line, the problem I'm guessing is that Tomcat runs at as service under the SYSTEM account. What permissions should I put on the shared folder to allow this, or is it a path problem?
    Any help would be appreciated.

    Starting the Tomcat service under the Administrator account fixes the problem, is there any reason I shouldn't use the Administrator account for this?

  • Problem for getting the real path using one servlet and one jsp page

    I have one tomcat machine and several virtual domains. Eahc virtual domain has one realpath in the disc.
    I am using one servlet and one jsp page for using this servlet.
    my purpose is to load, using the servlet , the real path for the domains (eahc domain has its path).
    for this i make this:
    the servlet code is this:
    package utils.ticker;
    import java.io.*;
    import java.io.File;
    import java.io.IOException;
    import java.net.*;
    import java.util.*;
    import java.text.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.Filter;
    import javax.servlet.FilterChain;
    import javax.servlet.FilterConfig;
    import javax.servlet.ServletContext;
    import javax.servlet.ServletException;
    import javax.servlet.ServletRequest;
    import javax.servlet.ServletResponse;
    public class Edicion extends HttpServlet{
    public Edicion() {
    public String cc(){
    ServletContext myContext= getServletContext();
    String abspath = myContext.getRealPath("/");
    //here i want to return the real path
    return abspath;
    public static void main(String args[]){
    and the jsp page is:
    <%@ page import="utils.ticker.*" %>
    <jsp:useBean id="tick" class="utils.ticker.Edicion" scope="session"/>
    <html><head><body>
    <%
    tick.cc();
    %>
    </body></head></html>
    But this produces one error, NullPointerException and dont shows me the real path.
    Can anyone help me?
    thanks

    i have put this into one sevlet:
    package utils.ticker;
    import javax.servlet.ServletContext;
    public class Edicion{
    private ServletContext myContext;
    public Edicion(ServletContext myContext) {
    this.myContext = myContext;
    public String getCC(){
    return myContext.getRealPath("/");
    and in the jsp page this:
    <%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*"%>
    <%@ page import="utils.ticker.*" %>
    <jsp:useBean id="tick" class="utils.ticker.Edicion" scope="session"/>
    <html><head><body>
    <%=tick.getCC()%>
    </body></head></html>
    but appear this error in the tomcat.
    Can you, please, help me. i am trying to solve this during one week and i am desesperate.
    Thanks.
    ERROR:
    HTTP Status 500 -
    type Exception report
    message
    description The server encountered an internal error () that prevented it from fulfilling this request.
    exception
    org.apache.jasper.JasperException: class utils.ticker.Edicion : java.lang.InstantiationException: utils.ticker.Edicion
         at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:248)
         at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
         at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:260)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2415)
         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
         at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
         at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:432)
         at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:386)
         at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:534)
         at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:530)
         at java.lang.Thread.run(Thread.java:536)
    root cause
    javax.servlet.ServletException: class utils.ticker.Edicion : java.lang.InstantiationException: utils.ticker.Edicion
         at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:533)
         at org.apache.jsp.pruebas_jsp._jspService(pruebas_jsp.java:72)
         at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:137)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:204)
         at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
         at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:260)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2415)
         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
         at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
         at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:432)
         at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:386)
         at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:534)
         at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:530)
         at java.lang.Thread.run(Thread.java:536)
    Apache Tomcat/4.1.18

  • How do you get the web application path from the servlet?

    I have created a web application which is installed in
    /webapps/myApplication
    /webapps/myApplication/data/users.xml
    /webapps/myApplication/WEB-INF/classes/myServlet
    How can you get the path to the "users.xml" file from the "myServlet" file?
    The code below doen's seem to return the xml file. anybody knows why?
    public class myServlet extends HttpServlet {
    public void doGet( HttpServletRequest req, HttpServletResponse res ) throws ServletException, IOException
    File myXmlFile = new File("/data/users.xml");

    Try this..
    String FileName = getServletContext().getRealPath("\\data\\users.xml");
    File myXmlFile = new File(FileName);
    hope this helps..

  • Regarding path resolution for PDF document

    Migration from weblogic 5 to 7.We are having problems while accessing PDF files
    from a particular folder(say C:\PDF\324322_a.pdf).We are using a utility called
    eMatrix to check out the PDF files to a particular location and the path of the
    location is mentioned in a .java file as a constant (PATH = c:\PDF\). The file
    gets opened successfully when we move the file to the root directory and change
    the constant to (PATH = C:\) Could you please help us to resolve the path from
    the particular folder?

    Which part of the Acrobat SDK are you using?

  • How to get tomcat installtion path, java path n documents path in a servlet

    may someone help me get the folder and pathname for tomcat, java path and library path and also the pathname where the jsp documents are stored.
    Thanks in advance
    null

    Have a look at System.getEnv(String) and System.getProperties();
    String tomcatHome = System.getEnv("CATALINA_HOME");
    Properties props = System.getProperties();
              Enumeration<Object> keys =  props.keys();
              while(keys.hasMoreElements())
                   String key = (String) keys.nextElement();
                   String prop = System.getProperty(key);
                   System.out.println(key +" : " + prop);
              }

  • Java Path Resolution on Windows

    Today I was messing around with different Java versions and discovered that Java is a little more tightly integrated with Windows than I originally thought. Maybe it's just a JRE thing, and not a JDK thing. I don't know.
    I have both Java 5 and Java 6 installed, and was trying to back down to Java 5 for a moment (investigating a "cannot access <whatever>.class" compiler error). I updated all of my environment variables (Windows XP) to point to the Java 5 JDK folder. But it was still using Java 6 JRE. So I moved the Java 6 JRE folder to a super-secret-haha-you-can't-get-to-it-now location. This gave me the following error:
    Error: could not open 'C:\Program Files\Java\jre6\lib\i386\jvm.cfg'
    Doesn't matter that all of my environment variables point to the Java 5 JDK, somehow invoking java from anywhere other than the Java 5 JDK bin folder causes some other handler to try and look up configuration from the JRE 6 folder that no longer exists.
    Can anyone shed some light as to what is handling the command line call to java without letting it defer to the Java 5 JDK referenced in the path?
    I guess I'll just see if I can uninstall the Java 6 JRE.

    Java.exe goes in \windows\system32. It is just a stub that refers to the correct JRE based on the registry HKLM\software\JavaSoft\Java Runtime Environment, which contains some keys pointing to Java 1.6.
    Therefore, I would try to add a path to the desired java.exe from the JRE directory BEFORE \windows\system32.

  • Set Path for running servlets

    Hi,
    Just started learning JSP.
    Am trying to run the helloworld.java
    from command prompt has c:\Tomcat 4.1\webapps\examples/WEB-INF/classes/HelloWorld.java.It says pacakage javax.servlet.http doesnot exist.Why is this?am i doing some thing wrong?
    I tried to run it from Tomcat as well.
    http://localhost:8080/examples/WEB-INF/classes/HelloWorld.java
    It says The requested resource (/examples/servlets/helloworld) is not available.
    Any help appreciated
    Thanx
    Shenoy

    You can not run servlets from the command line. You need to run them from the browser. The url should look like:
    http://localhost:8080/examples/servlet/HelloWorld.java
    Look at the tomcat examples at
    http://localhost:8080/index.jsp

  • Relative path to file in servlet class file

    Hello,
    I have several classes running as a Tomcat Servlet on my server. However, I have one class that I would like to access a file on the server.
    The problem is, what path do I use? I want to use a relative path as the servlet might be moved and I don't want to recompile each time the servlet is moved. For instance, I placed the file in the servlet directory under webapps in the same level with the WEB-INF directory. However, using "../../text.txt" does not seem to access it.
    What path should I use?
    Thanks in advance.
    Chris

    This is what I have done:
         String FS = System.getProperty("file.separator");
         String ctx = getServletContext( ).getRealPath( "" ) + FS;
         URL url = new URL("file", "", ctx +   "somefile.txt");
         //Create a BufferedReader for reading the inputstream.
         BufferedReader br = new BufferedReader(new InputStreamReader(url.openStream()));This gets you back to the "root", or one level above WEB-INF. Add the folder name where the file is located. As in      URL url = new URL("file", "", ctx +   "theFolder/somefile.txt");HTH,
    WalkGood

  • Finding the Path From Servlet

    Please guys I need some help on this.
    I have created a context in my Tomcat/webapps called EcBugManager.
    My servlets are in the webapps/EcBugManager/Web-Info folder.
    I want to say in a servlet to upload files to a folder
    which is in the webapps/EcBugManager/UploadFiles folder.
    How should i give the relative path from the servlet.
    I have tried the following but with no success.
    - "..\\EcBugManager\\UploadFiles";
    - "..\\UploadFiles";
    This works, but i need the relative path
    - "D:\\Tomcat\\webapps\\ EcBugManager\\UploadFiles";
    Is the way i am trying to do is wrong. please help on this.
    Rhanks in Advance
    Shiran

    The question doesn't clear enought.
    but you may try HttpServletRequest.getPathTranslated(), which returns
    the root path of your servlet.
    then you may append the sub-directory you want to located.
    or try servlet's creatTempfile method.

  • How to return URL of servlet path ?

    Hello,
    I want to return the URL of current servlet path (such as "http://www.mydomain.com:888/servlet"). How can I do that ?
    thanks in advance...

    Hi danisment,
    Checkout the API for javax.servlet.http.HttpServletRequest Interface in which you have the methods to get path information.
    Use
    request.getServletPath();Returns the part of this request's URL that calls the servlet. This includes either the servlet name or a path to the servlet, but does not include any extra path information or a query string.
    If you want the entire URL,
    use request.getRequestURL(); returns the StringBuffer
    The returned URL contains a protocol, server name, port number, and server path, but it does not include query string parameters
    Hope this will throw some light for you problem.
    Thanks,
    Sanath Kumar

  • 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).

Maybe you are looking for

  • Application menu not showing in preference pane

    Have brought some games for the iphone and ipod touch but have no application menu not showing in preference pane to upload them to to ipod touch. All software is current both itunes and ipod touch Help would be very grateful,

  • Question about burning CDs

    I bought a few albums from iTunes to put on my MBA. I want to burn one of the albums onto a CD but I don't have the external optical drive. Is there anyway to do this wirelessly? What should I do?

  • Cannot authorize to asmx - webservice from a workflow

    Hello everybody! I made a workflow for sharepoint 2013, including the "call http web service"-action. Therein I am trying to access https://mysp.com/sites/mysite/_vti_bin/lists.asmx via GET Request. So nothing fancy one might think, but somehow it is

  • Can I delete the files under C:\Users\MyAccount\CS6 Master Collection\Adobe CS6

    After installation I've been left with a ton of files under C:\Users\Nathan\CS6 Master Collection\Adobe CS6 - 8.3GB. Are these files actually needed? They seem to mostly be setup files. Can I just delete them after installation?

  • Assigning Role

    Hi All, I have one question for you. If i have 75 Profiles and i want to make it as one role. i.e I want to make it as one role with all 75 profiles. Is that possible??. If it's possible please let me know. Regards, Zeemaaa