Tomcat Vs Weblogic .. jsp/html file path issue..

Tomcat gurus, please help !!!
Development Env. :
OS: Window NT 4.0 SP6
Web Server: Tomcat 4.1.12
Sun JDK 1.3.1
IDE : Eclipse 2.1
Deployment/Testing/Prod Env:
OS: Sun Solaris 2.8
Web Server: Weblogic 5.1 SP 12
Sun JDK 1.3.1 IDE : N/A
Confession: New to Tomcat world.
Note: Reason why I'm using Tomcat for development though I can use Weblogic, Eclipse IDE with Tomcat plugin provides debuging functionality, thus the problem. I have an enterprise application being built and kind of stepped into a problem. I have a Servlet that marshals all the calls and process them through java beans ( about 50+ ) and content displayed through JSPs.
Here is the directory structure,
/AppContext
| +- src
| +- com.xyz.wfservices
+- jsp
main.jsp
+- WEB-INF
|
+ classes
+ com.xyz.wfservices ( compiled classes )
For Weblogic: It has 2 parameters to specify where the compiled code is and where the docs are,
=> weblogic.httpd.servlet.classpath=c:/wfservices/WEB-INF/classes
=> weblogic.httpd.documentRoot= c:/wfservices/src/html
and to register instance,
weblogic.httpd.register.WfServices=com.xyz.wfservices.WfSvcsController
weblogic.httpd.initArgs.WfServices=\
     main.properties=c:/wfservices/src/properties/wfservices.properties
But, I looked at Tomcat it is quite different.. it has <Context path="/wfs" docBase="L:\app_services\wfservices" workDir="L:\app_services\wfservices\work" /> Servlet def in web.xml
<servlet>
<servlet-name>WfServices</servlet-name>
<servlet-class>com.xyz.wfservices.WfSvcsController</servlet-class>
<init-param>
<param-name>main.properties</param-name>
<param-value>c:\wfservices\properties\config.properties</param-value>
</init-param>
     <servlet-mapping>
          <servlet-name>WfServices</servlet-name>
          <url-pattern>/WfServices</url-pattern>
     </servlet-mapping>
</servlet>
Probem: Accessing JSP/Html ... documents. weblogic accessing / calling jsp ..
     rd = req.getRequestDispatcher("/main.jsp");      //req is HttpRequest
     if (rd != null)
          rd.forward(req, resp);
The same does not work under Tomcat because it can find files relative to the context, thus it fails. I have to change the code like below to make it work.
     rd = req.getRequestDispatcher("/src/jsp/main.jsp");
     if (rd != null)
          rd.forward(req, resp);
It is a nightmare now to maintain two different environments and more over changing all the references and and its internal references is not feasible. The question is, is there a way to configure docBase in tomcat so that I won't need a code change.
Any help or inputs are greatly appreciated.
Thanks
Meher

I ran into this same problem before, so I created a utility class that would map out a URI or URL given a relative path. It's nice because it will detect and include non-standard ports for both the HTTP and HTTPS protocols. If you access a servlet/jsp using HTTP, it will return a URL for the HTTP protocol and the same for HTTPS. So, that means you don't need any code changes to access things through HTTP or HTTPS :) Here it is, hope it helps you out:
import javax.servlet.*;
import javax.servlet.http.*;
public class ContextMapper
    private static final int HTTP_PORT = 80;
    private static final int HTTPS_PORT = 443;
     * This method will return a URI to access a resource given its relative
     * path.  Please note that the relative path should start in the directory
     * where the web application is deployed to.
     * @param HttpServletRequest request
     * @param HttpServletResponse response
     * @param String relativePath
     * @return String
    public static String getUri (HttpServletRequest request, HttpServletResponse response, String relativePath)
        return request.getContextPath() + relativePath;
     * This method will return a URL to access a resource given its relative
     * path.  Please note that the relative path should start in the directory
     * where the web application is deployed to.  Also, the protocol will be
     * automatically detected from the request.  Supported protocols include
     * HTTP and HTTPS.  For all other protocols, the relative path will be
     * returned unmodified.
     * @param HttpServletRequest request
     * @param HttpServletResponse response
     * @param String relativePath
     * @return String
    public static String getUrl (HttpServletRequest request, HttpServletResponse response, String relativePath)
        if (request.getProtocol().startsWith("HTTP/") == true)
            switch (request.getServerPort())
                case HTTP_PORT:
                    return "http://" + request.getServerName() + request.getContextPath() + relativePath;
                default:
                    return "http://" + request.getServerName() + ":" + request.getServerPort() + request.getContextPath() + relativePath;
        else if (request.getProtocol().startsWith("HTTPS/") == true)
            switch (request.getServerPort())
                case HTTPS_PORT:
                    return "https://" + request.getServerName() + request.getContextPath() + relativePath;
                default:
                    return "https://" + request.getServerName() + ":" + request.getServerPort() + request.getContextPath() + relativePath;
        else
            return relativePath;
}Here are a few examples of using this class:
String uri = ContextMapper.getUri(request, response, "/css/basic.css");
String url = ContextMapper.getUrl(request, response, "/css/basic.css");
String uri = ContextMapper.getUri(request, response, "/images/image.gif");
String url = ContextMapper.getUrl(request, response, "/images/image.gif");
String uri = ContextMapper.getUri(request, response, "/jsp/HelloWorld.jsp");
String url = ContextMapper.getUrl(request, response, "/jsp/HelloWorld.jsp");
String uri = ContextMapper.getUri(request, response, "/servlet/HelloWorld");
String url = ContextMapper.getUrl(request, response, "/servlet/HelloWorld");

Similar Messages

  • JSP:  Include file paths

    Hi;
    I'm using Tomcat 3.2.
    I am trying to use the path "../common/copyright.html" for an include
    path. It isn't working.
    For some reason it seems you can't "go backwards" with a file path
    with Tomcat 3.2/JSP include file paths.
    Is there a way around this or does anyone know anything about it?
    ( I read the specs, they weren't of much help and I couldn't find
    much be searching google.)
    Thanks in advance
    Steve

    Try using the full (or absolute) path. If that does not work, then talk to Tomcat developers. If it does, then look at where the JSP pages lies in relation to the path you are trying to use the "../" method on.
    Example:
    JSP path: www.you.com/jsp/pages/hello.jsp
    Include path: ../jsp/pages/open.jsp
    This will cause an error becuase the path of the JSP page does not exist within the include path.

  • Local html file path setting

    Hi,
    I tried to use StageWebView to load a local index.htm which is saved in "src/assets" folder for Flex 4.5 mobile.
    I've tried different path settings but all failed. Please help, thanks!
    protected var webView:StageWebView = new StageWebView();
    protected function onViewActivate(event:ViewNavigatorEvent):void
      webView.stage = stage;
      webView.viewPort = new Rectangle(20, 100, 450, 450);
      webView.addEventListener(LocationChangeEvent.LOCATION_CHANGE,onURLChange);
      // StageWebView can't load the html file.
      // webView.loadURL("file://assets/index.htm"); 
      // webView.loadURL("assets/index.htm");  
      addEventListener(ViewNavigatorEvent.REMOVING,onRemove);

    That's quite alright. These forums are one of the best places to start learning!
    Unfortunately, Acrobat doesn't offer much flexibility when it comes to saving the data file produced when you export/submit data from the form. While you can't preset the path, you do have a little bit of control over the data file name which should, by default, be the same as the name you gave to the file containing the form (XDP/PDF). The catch is that if your form is loaded via a browser, it'll first get saved to a temporary folder and temporary file name. When the user exports the data and the XML data file is created, it'll have the temporary file name as its default file name (which will be bunch of letters and numbers, e.g. "FSA1U483.xml").
    I think you would be best to let Acrobat's UI take care of letting the user specify the folder and file name.
    Stefan
    Adobe Systems

  • How To Access JSP Image file Path inside JavaBean Class

    In my Webapplication,i have jsp and javabeans files. i need to send one image file path contains in Image folder to JavaBean[MyBean.java].
    From MyBean i am trying to display that image using PdfGen Application[JAR] in a new PDF Document.
    The Web Application Structure is as
    MyWebApp
    Image
    \ mypic.gif
    JSP
    \myjsp.jsp
    WEB-INF
    classes
    \pack.MyBean.java
    My Question :
    Inside the webapplication[JSP] the image file is accessed as a URL.(like http://localhost:7001/mywebapp/Image/mypic.gif). but From JavaBean: How To access this file? becz inside javabean it needs a complete system path..How to solve this problem? plz send me any solutions related to my problem....Thank U.

    Dear Madruguinha!
    Thank you very much for your tips.
    but i find another one method for accessing the image.
    // Inside Servlet or JSP
    String realPath=getServletContext().getRealPath("Image"+"/pic1.gif");
    Now we can send this exact system path variable to any java beans or java class that needs the image path as "drivename:\foldername\filename" like "c:\myflolder\mypic.gif" and not web context path.

  • Published swf and html file viewing issues.

    Greetings,
    I design web banners and used to, with Flash 8, sedn my
    clients the published *.html and *.swf files to download onto their
    desktops so they could view the banner. With Flash CS3 this doesn't
    seem to be working the same way. It keeps giving them the window
    that says something about "ac_runactivescript.js". How come this
    never did this with Flash 8?

    click file/publish settings/formats, make sure the swf and html boxes are selected, and click the use default names button.  then click file/publish.  are the files in your directory with your fla?
    if not, create a new directory (that has no subdirectories), save your fla to that new directory using a new name (ie, click file/save as).  then click file/publish.  check the new directory for your 3 files.

  • File path of open data storage

    Hello all!
    Now I'm using the blocks of open data storage, write data and close data storage for storing and extracting result data. For the file path issue, before I
    set the data path by double clicking the "open data storage" block and inserting the file location in the indicated place, and that worked!
    Now since I made a stand alone application of this program and shall use it in other computers, the file location I inserted in open data storage block isn't
    valid any more in other PCs. So I modified my source code by connecting a "current vi path" to the open data storage block's file path node instead of
    inserting it inside the block, and this doesn't work! During running there shows an error in the write data block saying that the storage refnum isn't valid!
    I'm wondering why I couldn't specify the file path like this. Any way to allow me to specify the file path as the current vi path?
    Thanks!
    Chao
    Solved!
    Go to Solution.

    You need to account for the path changes when built in to an application, have a look at this example.
    https://decibel.ni.com/content/docs/DOC-4212
    Beginner? Try LabVIEW Basics
    Sharing bits of code? Try Snippets or LAVA Code Capture Tool
    Have you tried Quick Drop?, Visit QD Community.

  • Help Needed in opening a HTML File from swing application

    Hi,
    I am opening a HTML file in Internet Explorer from my swing application.
    I am using the code given below
    private final static String WIN_FLAG = "url.dll,FileProtocolHandler";
    private final static String WIN_PATH = "rundll32";
    String cmd = WIN_PATH + " " + WIN_FLAG + " " + url;
    // url is HTML file Path
    Process p = Runtime.getRuntime().exec( cmd );
    The HTML file is opening up,but it always opens behind the swing application,that makes me every time to maximize the HTML file after it being opened up.
    I want to open it in front of the Swing Application.
    Any Help Please ?
    - Manikandan

    Check your Application's JFrame properties (may be ur Frame is set to be in top position ,always),and also check running your application in some other OS.

  • Question re: moving iTunes library to new computer where files have different file path?

    Hi everyone-
    I just got a new laptop and need to transfer my iTunes library to the new computer.
    On my old computer, the hard drive was partitioned into a "C" drive and an "F" drive. The new laptop is just "C."
    Since my iTunes library was on the "F" partition on the old laptop, the file path for all the files is going to change when I transfer to the new laptop.
    I can find dozens and dozens of articles online about how to move iTunes to a new computer, but none of them seem to address the file path issue.
    Does anyone know where I can find detailed instructions on how to make this work?
    Thanks in advance.

    Quit iTunes.
    Move the entire /Music/iTunes/ folder to the F: drive.
    Hold Shift & launch iTunes.
    Select Choose library... and select the iTunes folder you moved to the F: drive.
    Everything should still work fine.
    Now go to iTunes prefs > Advanced.
    Set the iTunes media folder location to the iTunes folder you just moved to the F: drive.
    iTunes menu File > Library > Consolidate library.
    This will copy all your media into the iTunes folder (F:\iTunes\iTunes media\ folder)
    Let it finsh.
    Quit iTunes.
    Then you can copy the F:\iTunes\ folder to the new computer.
    If you copy it to /Music/ folder, just start iTunes and it'll work.
    If you copy it elswhere (such as another drive) hold Shift, launch iTunes, select Choose library... and select the iTunes folder.

  • Jsp+Tomcat: Is there a max number of lines in a html file generated?

    Hi, I write a jsp page that does a lot of queries on a database and, for each query, views a table with the records return by the query. I have a problem: if the number of queries is low the page work well; if the number of queries is high the page has been truncated. If a watch at the html file of the browser it's like truncated. Are there any parameters that i have to modify? thaks very much

    Truncation usually indicates that an exception occurred after the response had already been committed (due to the output buffer becoming full which will cause it to be flushed).
    check out the logfiles of your webserver if there are any unexpected exceptions in there.

  • Using a real file path to include a JSP using RequestDispatcher

    Hi,
    I am trying to figure out how to use RequestDispatcher inside a servlet to include a jsp page using a real file path instead of a context path. So for example I would want to do something like...
    RequestDispatcher rd = this.getServletContext().getRequestDispatcher("c:/tomcat/conf/think.jsp");
    Is this possible? tomcat is complaining that the path does not start with a "/"
    From a higher level I am trying to setup a solution where all of my web applications can share a set of global jsp pages and other resources. I know the easiest solution would be to put everything into one web application but this does not make sense in my situation because I have differnet web applications for different companies on the same server. Any help would be greatly appreciated. - krebsnet

    First of all...
    My test environment is Tomcat 4.1.24 and it runs on port 80 as my webserver as well.
    I can place the .jsp (or .html) in the shared folder. Not in the lib or class folders but right in the shared folder. I can then call it from multiple contexts without using the context path. Just tested it a minute ago. For example I have test.jsp in the shared folder and loaded it from two separate contexts (one named /demo and one named /inetapps) by calling Load test. It loaded in both of them and neither contain a test.jsp file.

  • Relative path for HTML file

    Hi ,
    This is my requirement. In the ESS Personal information overview page, I can add a HTML file to the additional information section.
    I have created a HTML file by creating a web module and enterprise application and deployed the same through NWDI.
    I declare a resource wher ei mention the path. Here i specifed the complete path of the html file ... like
    http://hostname:portname/addinfo/addinfo.html.  Which i know is a wrong thing to do since when i move the html filel to the production system it will still be accessing the html file in the dev system.
    How do i give the relative path here so that the html file accessed is from the production system when we  go-live.
    Please suggest.
    regards
    sam

    Hi,
    One simpler solution is to use an AppIntegrator iView, as explained in the weblog <a href="https://www.sdn.sap.com/irj/sdn/weblogs?blog=/pub/wlg/2786">Integrating your Web Front-ends into the SAP Enterprise Portal using the Application Integrator</a>. It worked well for us.
    You can remove the user authentication part in the portalapp.xml if you don't need it.
    Regards,
    Martin

  • How to include HTML file in JSP using HTML elements or Javascript?

    Hi,
    I have around 15000 static html files one for each item which we display each upon invoking an item.The HTML file should be part of a JSP file.
    Please note that the name of the HTML file is determined dynamically
    Placing all the HTML files within the web application does not give us good performance so i would like to put all of them in the webserver.
    I am not able to include the file in the JSP using the jsp:include attribute if i place the HTML files in the webserver ,
    in order to do that i think should use either HTML element or javascript to include the HTML in the JSP.is there any alternative to <Jsp:include>
    Does anyone have an idea how to include the HTML file and take advan tage of webserver?
    Any ideas are appreciated

    What you need to do is simply read the HTML file from the disk and dump it out to the outputstream. It really is that simple.
    There's no reason you need to include all 15000 files in the actual WAR, you can place those files any place handy that is easy for the application to see (in another directory, or accessible from a file server if you have multiple front ends).
    Then, just write a utiility function that takes the output stream (i.e. the 'out' JSP variable), and the file name, read the file, and write it to the stream.
    If you start noticing performance issues, then you can try doing some caching, but truth is your OS should be doing that for you.
    But, truth be told that's the only practical way to do it.
    Another solution would be to use JavaScriipt and XMLHttpRequest (i.e "AJAX") to load the file at the client side, and simply replace a tag with the results.
    That's also pretty trivial to write, any web site talking about AJAX should give you hint there.
    Of course, that won't work for folks who have JavaScript turned off, or some other incompatible browser, whereas the server side solution obviously works everywhere.

  • Choice between html & jsp type files

    Usually, while developing applications, there is a common header and footer for all pages.Such header and footer pages can either be saved as a jsp file or as a html file. If there are no dynamic contents in the header & footer file, then,is it advisable to save them as html pages and then use the <% @ include file="header.html" %>. Or is it advisable to have it as a jsp file and access it using the tag <jsp: include page="header.jsp">.

    If you use the "<% @ include file="header.html" %>" method, all you are doing is copying source code during the pre-compile stage. Whether you title your page header.jsp or header.html, all of it gets dumped into the resulting JSP page, which then gets compiled into a servlet. So, with the include file method, it makes no difference.
    The <jsp:include> method requires the response to temporarily go to the header.jsp servlet to get the text, and then it will merge it with the file's text before sending it out. This is probably slower than having it all done at precompile time. However, using the <jsp:include> allows you to program the code independently without worrying about the code mixing (for example, both the header and your main page can have variables with the same name on them since the servlets are run independently and their outputs are the only things that merge). In your case, however, this isn't an issue.

  • "Java file" & "Jsp file" compilation issues in Eclipse

    Hi,
    Eclipse
    Question 1:
    I have set the value for preference->java->Installed JREs as : j2re1.4.2_07 not to jdk
    When I write a java file, its compiling, how? From where its using "javac" exe file for compilation.
    Question 2:
    Whereas in prefrence->Tomcat->JVMSettings -> JRE(drop down box) set value as j2re.1.4.2_07
    When I write a jsp file as follows
    index.jsp
    <html>
    <body>
    <%java.util.Date d = new java.util.Date();%>
    Todays date is <%= d.getDate()%> and this jsp page worked!
    </body>
    </html>
    when i try to save this file & strat tomcat I got exception as follows:
    Exception:
    org.apache.jasper.JasperException: Unable to compile class for JSP
    An error occurred at line: -1 in the jsp file: null
    Generated servlet error:
    [javac] Compiling 1 source file
    Please clear my doubts.
    Thanks,
    Hari

    Try going into your TOMCAT_HOME/conf/web.xml and look for this section:
    <servlet>
    <servlet-name>jsp</servlet-name>
    <servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class>
    <init-param>
    <param-name>logVerbosityLevel</param-name>
    <param-value>WARNING</param-value>
    </init-param>
    <init-param>
    <param-name>fork</param-name>
    <param-value>false</param-value>
    </init-param>
    <load-on-startup>3</load-on-startup>
    </servlet>
    Change the <param-value> for fork from false to true and see if that helps.
    Otherwise it's a problem with your JSP.

  • Jsp:include an html file in a subdir

    I have the following directory structure and files
    $CONTEXT/articles.jsp
    $CONTEXT/articles/article1.html
    $CONTEXT/articles/images/image01.gif
    When I browse to
    http://$SERVER/$CONTEXT/articles/article1.html
    the article and its image display fine. The file article1.html references the image via an href to "images/image01.gif".
    However, when I try to access the article from articles.jsp via a <jsp:include page="articles/article1.html" flush="true"/>, the article1.html can't find its image. Obviously this is a problem with the relative path to the image.
    I want to be able to correctly view article1.html from directly browsing it and from including it from articles.jsp. How can I include the article1.html from articles.jsp and somehow allow article1.html to find its images? Is this possible?
    Best regards and thanks,
    John

    I have just tried what you say doesn't work, but I have no problem getting it to work. You may want to check your syntax.
    My directory structure is as follows
    SERVERNAME/CONTENT/jspinclude.jsp
    SERVERNAME/CONTENT/inc/inc.html
    SERVERNAME/CONTENT/inc/images/myimage.gif
    my jsp file looks like this:
    <HTML>
    <HEAD>
    <TITLE>Untitled Document</TITLE>
    <META http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </HEAD>
    <BODY bgcolor="#FFFFFF" text="#000000">
    This is a test of a jsp.include
    <jsp:include page="inc/inc.html" flush="true" />
    </BODY>
    </HTML>
    my html file looks like this
    <HTML>
    <HEAD>
    <TITLE>Untitled Document</TITLE>
    <META http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </HEAD>
    <BODY bgcolor="#FFFFFF" text="#000000">
    <P>This is some sample text</P>
    <P><IMG src="images/myimage.gif"> </P>
    </BODY>
    </HTML>
    This seems to work fine. Perhaps the problem exists somewhere else.
    Rob

Maybe you are looking for

  • Need info on automating SAP email to PO requestors for AP events

    Hi Friends,           Is there any BADI for triggering the PO(Invoice changes). For example when an invoice posts against a PO the system could automatically send an email to the PO requestor in SAP that this invoice was posted against this PO.It is

  • Is it ok to leave my iPad in the cold

    Is it ok to leave my iPad in the cold

  • Mail Merge & cell references

    Hi @all, I have several tables in numbers (09). On is for users input, the other for calculating values I need in a mail merge. In the first table, the user types a date in this format "DD.MM.YYYY hh:mm" (german datetime). In the second table, there

  • EP 70 connectivity with ECC 6.0 (SAP NW2004s)

    Hi, I have recently upgrade r3 4.7 (32 bit) to ecc 60 (64bit) We also install EP 70 (NW2004s SR3) I am not able to connect Enerprise Portal 70 to ECC 60 system Also how to put ESS business package in EP regards vikas nagar

  • Another Boot Camp question

    Sorry-when installing boot camp on my 17" macbook pro, the windows installation screen 'stalls' at the 'Welcome to setup' screen. I am supposed to hit the 'enter' key to continue, but at this point my keyboard becomes inoperable. (no key seems to fun