How to change the contextPath of JSP?

Hi all,
I feel this is a common problem all new JSP developers will experience. But I couldn't find a feasible direct solution over the net. Before explaining the problem let me display my directory structure:
the war file has the following structure:
testurl.war\
        |
        +html\
        |     |
        |     testhtml.html
        |
        +jsp\
        |   |
        |   welcome.jsp
        |
        +images\
               |
               test.jpgapart from this I have a servlet which is mapped in web.xml as \Welcome.
     my problem is that I have a link in welcome.jsp to testhtml.html which is given as shown:
<a href="../html/testhtml.html" >Welcome </a>1. It works fine when I directly access the url      "//http:localhost/testurl/jsp/welcome.jsp"2. The servlet mapped to /Welcome just forwards the request to welcome.jsp
using:
     request.getRequestDispatcher("jsp/welcome.jsp").forward(request,response);when I access the servlet as "//http:localhost/testurl/Welcome", the jsp appears
but the link does not work.
in first case the link is shown as "//http:localhost/testurl/html/testhtml.html" (works fine)
in second case the link is shown as "//http:localhost/html/testhtml.html" (problem)
anyone please help me to find a workaround to this problem..
thanks and regards,
Gireesh.

1. Will the
'getContextPath()'
method always return the application name (the >war file name)?Well it returns the path where application(war) is being deployed on a WEB / APPSERVER
wid reference to TOMCAT it considers %CATLINA_HOME%\webapp as the root and it returns the offset PATH for that root.
just to get more insightful information try with request.getRealPath(""); which would return the whole path w.r.t server machine say something like
"C:\program file\tomcat\webapps\mywebapp" which cannot be applied to the above senario....
or, will this be enough?
request.getContextPath()+"/html/testhtml.html
so that there is no problem of session invalidation..Well i don't think so as that would add up to the present path which would be look like
"WEBAPP/jsp/"+request.getContextPath()+"/html/testhtml.html" well i haven't tried it myself its just a prediction which can happen.However you are always welcome to try it as that can even be my misconseption.... too :)

Similar Messages

  • How to change the date format?

    Hi,
    I need to display the data format as(YYYY-MM-DD). But now it displays(2009-1-9)
    Here is my code snippet which i used to display the data format as(2009-1-9)
    *<INPUT TYPE=TEXT NAME="date_submitted" MAXLENGTH=20 SIZE=10 VALUE="" onBlur= "return dateSubmitted()">  (YYYY-MM-DD)*
    *<SCRIPT LANGUAGE="javascript">*
    dateSubmitted()
    *</SCRIPT>*
    function dateSubmitted()
                        if (document.pgUpdate.date_submitted.value == "")
                             date = new Date();     
                             month = date.getMonth() + 1     
                             document.pgUpdate.date_submitted.value =
                                            date.getYear() + "-" + month + "-" + date.getDate();
                        return true;
    Can anybody help me how to change the date format?
    Thanks in advance!

    prit123 wrote:
    use SimpleDateFormat class. The code is :He posted a Javascript related question, not a Java related question.
    Please use forums devoted to Javascript. You're here at a Java/JSP forum.
    There are JS forums at webdeveloper.com and dynamicdrive.com. Good luck.
    String formatPattern = "yyyy-mm-dd";
    SimpleDateFormat sdf = new SimpleDateFormat(formatPattern);
    sdf.format(yourdate);yyyy-mm-dd denotes year-minutes-days. Please go read the SimpleDateFormat API as well.

  • How to change the Hello Portlet in Jetspeed2 Demo

    hi ppl,
    I am having a big problem..
    I can't change the portlet title, hello portlet, in the jetspeed 2 demo.
    The strange things is that i am able to change the title of the pickANumber portlet.
    @ Portlet.xml
    <portlet id="PickANumberPortlet">
    <init-param>
    <name>ViewPage</name>
    <value>/WEB-INF/demo/simple/PickANumber.jsp</value>
    </init-param>
    <init-param>
    <name>HelpPage</name>
    <value>/WEB-INF/demo/simple/PickANumberHelp.jsp</value>
    </init-param>
    <init-param>
    <name>EditPage</name>
    <value>/WEB-INF/demo/simple/PickANumberEdit.jsp</value>
    </init-param>
    <portlet-name>PickANumberPortlet</portlet-name>
    <display-name>Pick a number game</display-name>
    <portlet-class>org.apache.jetspeed.demo.simple.PickANumberPortlet</portlet-class>
    <expiration-cache>-1</expiration-cache>
    <supports>
    <mime-type>text/html</mime-type>
    <portlet-mode>VIEW</portlet-mode>
    <portlet-mode>HELP</portlet-mode>
    <portlet-mode>EDIT</portlet-mode>
    </supports>
    <supported-locale>en</supported-locale>
    <supported-locale>fr</supported-locale>
    <supported-locale>ja</supported-locale>
    <resource-bundle>org.apache.jetspeed.demo.simple.resources.PickANumberResources</resource-bundle>
    <portlet-info>
    <title>Change TITLE</title>
    </portlet-info>
    <portlet-preferences>
    <preference>
    <name>TopRange</name>
    <value>100</value>
    </preference>
    </portlet-preferences>
    </portlet>
    See.. i just replace that data in the portel-info/title.. and it changes the title in the pickANumber portlet change..
    But strange! i can't do the same way for the hello portlet
    Can someone tell me how to change the title in the hello portlet...
    Pls help.. i am running out of time!

    The hello portlet uses the title string in property file, thus you may need to modify the file "demo\WEB-INF\classes\org\apache\jetspeed\portlet\helloworld\resources\HelloWorldResources_en.properties" to change its title.

  • How to change the library path from development machine to application serv

    hi
    how can i change the library path which i developed in windows machine and the library path is c:/fas/dss.pll and now i hosted all forms,menu,library and reports in application server that is running in linux machine now i want to know how to change the library path c:\fas\dss.pll to /oracle/fas/dss.pll.

    Hi !
    It is standard functionality to change ship-to party address in ISA B2C. This happens only from the checkout.inc.jsp. The ship-to party is part of the basket object.
    Cheers,
    Ashok.

  • How to change images dynamically in jsp?

    Hi All,
    i Want to know how to change images dynamically in jsp, for example in any site if u look at advertise or any images, it will be changed after every few seconds.
    Please guide me
    Thanks
    Sandesh S

    sandeshas wrote:
    Hi BlusC,
    i was searching your mail Id to ask the question directly to u,i checked in your blog also, but i didnt get,I want to keep my email spam safe. Only trusted people and direct friends have it. Just use the forums for discussion.
    my question is suppose if i want to display and change the advertise(adds from different company ) in my web site,how can i do it by using jsp?
    Do i need to create animated gifs which contains all company adds??one might be from movie add,after few seconds next one migth be some other web site add like that, how can i achieve this in my servet,jsp or using struts.You create animated gifs with an [animated gif editor|http://google.com/search?q=animated+gif+editor]. There is nothing what JSP can do for you here.

  • How to change the OraSSO login link in webcache/load balance

    Hi
    we have 10gAsR1 installed as a Portal instance. We have 6-server
    load balancer => webcache as loadbalancer (listening port 80)
    Wb ch1 and wb ch2 => webcache (listening port 7777)
    portal1 and portal2 => Portal listening 7778
    infra =>Infrastruture with repository Portal/Oracle SSO (listening 7777)
    This set up is working fine for our intranet setup, now we need to open this for couple of external clients. Well initially we need to open on the load balancer server on port 80 for external team to access, it works fine when we make it publc access.
    Now when we need to make it SSO (siteminder) enables, when users click on login link it first goes oracle sso then it internally redirects the page to site minder sso.
    Well, I have noted that the sso server details are mentioned in global setting sso/oid details. Since we need to open this for external client we have to add a DNS entry for this so that we can allow its access over firewall..
    Now I have made DNS name change at my infrserver level, now I need to update the change at the load balancer server (where wheb chache is running).
    Any one know how to chang the URL at load balancer.
    I am struck at this point please suggest how should i proceed..
    Thanks,

    Extract from Personalization Guide - Page Footer - Personalization Considerations
    * If you wish to personalize the URL that points to the Privacy Statement for a page that displays a standard Copyright and Privacy (that is, its Auto Footer property is set to true), set the Scope to OA Footer, in the Choose Personalization Context page of the Personalization UI.
    * If you wish to personalize the URL that points to the Privacy Statement for a page that displays a custom Copyright and Privacy (that is, its Auto Footer property is set to false), set the Scope to Page in the Choose Personalization Context page of the Personalization UI. In the following Page Hierarchy Personalization page , identify and personalize the Privacy page element.

  • How to change the privacy statement link url

    I looked into the previous threads , could not find the answer to "Changing the privacy statement url to clients privacy statement url".
    I am talking about the privacy statement URL in the page that user see it as soon as user logs into the e-business suite.
    I have read the previous theads and developers guide regading how to show or hide this autofooter thing. but could not find any thing about how to change the one in the login page.I even looked ino personalization but could not find a place to change this url. please HELP.
    Another question is " is it ok to show privacy statement in just the first page and hide it in rest of the application pages?"
    Thanks
    karan

    Extract from Personalization Guide - Page Footer - Personalization Considerations
    * If you wish to personalize the URL that points to the Privacy Statement for a page that displays a standard Copyright and Privacy (that is, its Auto Footer property is set to true), set the Scope to OA Footer, in the Choose Personalization Context page of the Personalization UI.
    * If you wish to personalize the URL that points to the Privacy Statement for a page that displays a custom Copyright and Privacy (that is, its Auto Footer property is set to false), set the Scope to Page in the Choose Personalization Context page of the Personalization UI. In the following Page Hierarchy Personalization page , identify and personalize the Privacy page element.

  • How to change the default apex port

    hi,
    i am installed apex4.0 in EBS R12 DB with HTTP Server method. my apex is running from application server 10g and default port is 7777.
    URl: http://hostname:7777/pls/apex
    My EBS R12 running on http://hostname:8007.
    is it possible to change the apex port to EBS Apache port(8007) in R12 and finally i want to change above URL like this
    Before change : http://hostname:7777/pls/apex
    After Change : http://hostname:8007/pls/apex
    Thanks in advanace....

    How to Change the Default SSH Port from Terminal ?
    now showing default SSH Port 22 i need change it pls help me how can do

  • How to change the default Path of Prompt Played by MicroApp

    Hi
    I need to store all the Self Service application prompts in dedicated Media Server. I can modify location of all the Media files by passing the related URL form CVP application, however I need to know how to change the default location of Prompt file played by Play Media Microapplication in ICM Scripting.
    Currently the default location taken by Play Media Micro App is the Media _Server.variable path set for VXML Server location while I have a separate Media Server.
    Please advice how we can customize the MicroApp Media path.
    regards
    Kapil Kumar

    Hi Kapil,
    Try this in your ICM script, define set variables i.e.
    set Media Server= ip address of media server
    set Locale = en-us
    set input Type = DTMF only
    set App Media Lib = " you new location i.e. test "
    So, the application path will be
    http://media server ip address/en-us/test
    hope this helps.
    Cheers

  • How to change the default SSH port on Cat 6500 WS-SUP720-3B

    I have been net searching this question and I find answers relative to other Cisco products but not for the 6500 series. We are running
    entservicesk9_wan-mz.122-18.SXF17a.bin and would like to know how to change the default SSH listening port..
    Thanks in advance..

    Hi Neil,
    Normally this is achieved via the "ip ssh port rotary " but unfortunately, this command is not implemented on your platform so ssh will only work on port 22.
    Regards,
    Nicolas

  • How to change the Default login script and the USER login script in Netware3.12

    I need to cut down the disk map from Neware 3.12 in Win98 client's PC.
    please tell me
    how to change the Default login script and the USER login script in
    Netware3.12 ?
    Or is there any other ways to do this thing?
    Thanks a lot!

    On 4/6/2006 [email protected] wrote:
    > how to change the Default login script and the USER login script in
    > Netware3.12 ?
    Please repost in the discontinued.forums.
    Edison Ortiz
    Novell Product Support Forum SysOp
    (No Email Support, Thanks !)

  • How to change the default database charset to ISO8859-1?

    Hi all,
    I have created a table with a nvarchar field to store string, may i now how to change the default NLS charset to ISO88591 charset?
    Thanks in advance.
    chin.

    Thank you!
    I will try later!
    But,who can tell me more detail !
    thx

  • How to change the default time?

    when you finish the action of dialing ,the CCM system recognize your finish after 10s .How to change the default time in Service Parameters ,which is the detail Parameters ?

    Please see the following link for information on configuring the interdigit timeout.
    http://www.cisco.com/en/US/products/sw/voicesw/ps556/products_tech_note09186a00800dab26.shtml
    Hope this helps. If so, please rate the post.
    Brandon

  • How to change the default currency in CJ32 and CJ33

    Dear all,
    As required by the user, I want to know how to change the default currency from controlling area currency to object currency in TCODE CJ32 and CJ33. Currently, the controlling area currency will be defaulted in the field "Views in".
    Could any one help me? Points will be awarded.
    Thank you.
    Christina.
    Edited by: Virendra Pal on May 5, 2010 8:34 AM

    Hi Christiana ,
    Once you are in tcode CJ30 / CJ32 , Enter either Project definition or WBS element and this shall take you to the Budget screen and once you are here you can find a drop down with two options .One is Controlling are currency and the other one is Object currency.
    Since the Currency is set to Object currency in OPS9, System shall allow the budget values in Object currency and if the user wants to see the same values in Controlling are currency ,then the user needs to view the values in Controlling are currency using the drop down .
    Regards
    Judy

  • How to change the default "Safe" files in Safari?

    I would really appreciate if anybody could teach me how to change the default "Safe" files using AppleScripts, Folder Actions or .plist files. I really would like to have some files to open automatically after download, specially .pps files, and safari doesn't recognize such files as "safe". I tried to find out reading the help files but got lost.
    I posted a reply in an old topic for somebody who seemed to know, but it was not related to that topic, so I decided to open a new one.
    I'll be gratefull for any help. Thanks.

    Hi MDRC,
    Have a read of [this topic|http://discussions.apple.com/thread.jspa?threadID=1237961] to see if that helps.

Maybe you are looking for