Get base URL during servlet init()

How can I obtain a Application Server's base URL during a servlet's init(), i.e. not using HttpServletRequest later
e.g. for servlet test accessible at http://localhost:8080/contextroot/test
base URL = "http://localhost:8080/contextroot/"
After some testing the closest I've got is "jndi:/server/contextroot/". Can I get a HTTP URL from this?
public void init(ServletConfig config) throws ServletException {
super.init();
try {
path = config.getServletContext().getResource("/");
} catch (Exception e) {
System.out.println("e: " + e.toString());
Any ideas appreciated. Thanks in advance.
Java EE 5

All what you have in the init() method is the ServletConfig. Have you checked its javadoc to see what it all offers?
[http://java.sun.com/javaee/5/docs/api/javax/servlet/ServletConfig.html]. Hint: check the other getters of ServletContext.

Similar Messages

  • Get "#"  from URL into servlet

    Hi
    I am writing a servlet which can check that the requested URL is having "#" or not.?
    Let's say my URL is like, http://abc.com/#/efg/hij.jsp
    As it is having "#' sign in the URL string, So I need to check the existence of "#" in requested URL.
    My problem is when I write ..
    StringBuffer url = request.getRequestURL();
    String requestedURL = url.toString();
    requestedURL only provides me the string before "#" i.e. http://abc.com/
    I need to check if it has "#" or not with whole URL string.
    Is there any way to check that into servlet.?

    The # sign is a client side sign telling it to go to a bookmark with the name following the # sign. The # sign is not part of the requested URL, so you can't get it on the server side.
    If you are generating URLs with the # sign and trying to make it do something you should re-think the design since the # sign is reserved for client side use.
    Alternatively you could try to pass any URL that does have the # sign through java.net.URLEncoded.encode(theURL, "UTF-8") to see if you can then get it back on the server.

  • How to get full URL in java?

    Hi,
    I am working in a spring & hibernate project. For the AJAX request to bookmark, I used RSH (Really Simple Framework) framework. So, my URL changes for the AJAX request as
    http://localhost:8080/courses#/medicaltranscription/cardiology
    If I bookmark this and open in a new window, I can’t get full URL in Servlet. If I use methods in Servlet, it gets only, upto http://localhost:8080/courses. I can’t get the whole URL. Please, help me to find a solution.
    Thank you

    The hash part is entirely client side. You cannot get it on the server side. You need to pass it as request parameter or as part of real URL.

  • How do I get the URL to "My Photo Stream" (the base one, Not the one I created to share out)?

    How do I get the URL to "My Photo Stream" (the base one, Not the one I created to share out)?

    You can't get a url for my photo stream; only for publically shared streams.

  • Which table stores this value Transmission Servlet Base URL

    Hi All,
    EBS r12 12.1.3
    From the screen in Payment
    Update Payment System: FirstDataNorth
    i am looking for table that stores this value
    Transmission Servlet Base URL
    did look in these tables FND_PROFILE*but not available.
    Please help!
    Regards,

    Hi,
    I am not sure, whether you are looking at the correct place. Can you also let us know what made you ask to check the infromation from table.
    But there are configuration file which stores these information. I believe the source we are looking info might be wrong.
    Also have a look at:
    Oracle Payments Implementation Guide
    Best Regards,

  • How do I get the URL of a jsp page which calls a servlet?

    I have a jsp page which will lead to a servlet, I can get the URL of the servlet, but how do I get the URL of the jsp page which lead to the Servlet in the servlet?

    You could try doing:
    request.getHeader("Referer");

  • How to get the base url

    Hi,
    when configure the BPM, we set the base url (http://host:port/), which will be used in the default notification sent by bpm.
    now we want to include that url in our notification step. is there a way to get that url?
    Best regards,
    John

    Hi John,
    Would you please share the solution you found for this problem, maybe the EJB source codes or something like that? It would really help the ones like me who have the same problem and looking for a solution.
    Thanks in advance...
    Best regards,
    Utku.

  • Difference between GET and URL Rewriting in Servlets

    What is the difference between GET and URL Rewriting in Servlets?.Please illustrate with an example.

    Thanks for your reply gimbal.
    GET appends query string at the end of the URL. URL rewriting also does the same thing. It also appends query string right?. Then what is the difference between two. I have this question in my mind for long time.To my surprise an interviewer asked this question in an interview also.

  • A base URL and shared secret - when dio you get these?

    My boss is the administrator for our universitys iTunes site. We are not public yet. I aked hime for the base URL and shared secret code adn he said he never got them. So when do we get them? We need them to program the API. De we need to set the site to "Borwse" to have them sent?
    If they were sent and lost can they be re-sent?
    Thank you,
    Chip

    Chip,
    If students, faculty, and staff can get to your site through a portal ... if your boss can access your site as an administrator, then there is no way that Apple did not send those strings to you. On the other hand, if you have never, ever accessed your iTunes U site, then it might be possible that you never generated site strings and your boss could very well be correct.
    Generally speaking, when you get a new iTunes U site approved, Apple sends the e-mail address listed on your school's application a "welcome" e-mail that contains a link that opens iTunes and shows you your site strings. If you don't have your admin credential handy, you can always return to get a copy of those strings, but only if you've previously associated an iTunes U administrator with an Apple ID (an Apple ID is the same ID you'd use, say, to buy music from the iTunes Store itself).
    If you no longer have that welcome e-mail or your site strings, you can ask that Apple resend that welcome e-mail ... and the best way to do that would be to contact your local Apple account executive or Apple service engineer and arrange it through them. If you don't know to whom you belong, we can help you find out.

  • Getting exception in log - Invalid external link base url

    Hi,
    I am using BI-Publisher Release 10.1.3.4 and I see that for all the reports I have in it, the below line is coming in my bi-publisher log.
    [092010_053617793][][EXCEPTION] Invalid external link base url: 'http://10.177.219.162:9704/xmlpserver/' -- the ip is my machine ip address.
    This line comes for every executing of the report. This is not causing any unwanted behavior but having an exception in log is always a concern from field.
    Can any one let me know what could be the reason for that exception?

    Hi,
    I come across the issue when I tried to view the BI Publisher report, the pdf report didnt load up and throws "[072811_123101921][][EXCEPTION] Invalid external link base url:" on the server console.
    with some the Acrobat error like "there is no page to display"
    Then I checked if the data was there or not in database table to which i had connected through the jdbc conection. I found that no data was present in the database tables. So i run the ETL process again setting some flags in the source database and then the data came up in the BI Publisher connected database.
    Then when I started Bi Publisher server and viewed the reports, it worked.
    Regards,
    krish

  • Web.xml - can't get the url from xml file..

    Hi all,
    Im a beginner @ jsp =)
    My question is as follow..I cant get base from the web.xml file.
    This is a shorten version of my web.xml..
    <web-app>
         <welcome-file-list>
    <welcome-file>Default.jsp</welcome-file>
    </welcome-file-list>
         <!-- Define the controller servlet -->
         <servlet>
              <servlet-name>ControllerServlet</servlet-name>
              <servlet-class>ControllerServlet</servlet-class>
              <!-- Define initial parameters that will be loaded into
              the ServletContext object in the controller servlet -->
         <init-param>
                   <param-name>base</param-name>
                   <param-value>http://localhost:8080/burnaby/ControllerServlet</param-value>
              </init-param>
    </servlet>
         <servlet-mapping>
    <servlet-name>ControllerServlet</servlet-name>
    <url-pattern>/ControllerServlet</url-pattern>
    </servlet-mapping>
    </web-app>
    And my jsp file:
    <%
         String base = (String) application.getAttribute("base");
         String imageUrl = (String) application.getAttribute("imageUrl");
    %>
    <table width="740" cellpading="0" height="75" cellspacing="0" border="0">
         <tr>
              <td align="left" bgcolor="#F6F6F6">
                   <font face="Verdana" size="3">Sky's E-mall!</font>
              </td>
              <td align="right" bgcolor="#F6F6F6">
                   <a href="<%=base%>?action=displayShoppingCart"><img border="0" src="<%=(imageUrl + "cart.gif" )%>"></a>
                   ���
              </td>
         </tr>
    </table>
    I have written it of a book im reading and i cant get it to work. Base and imageUrl always become null.
    thank you
    /Robert

    I'm a little new to JSPs and servlets too, but I'll give this one a shot. I think since your variables like 'base' are servlet initial parameters, they don't get initialized until you actually call the servlet ( I'm not 100% on this, though). Try calling the servlet and having it forward the response back to your original JSP and see if you get values then.

  • Custom SSO & base URL settings

    Hi All,
    We are just implementing our Custom SSO product with 5.0.4 for windows. The basic implementation has gone very well but I do have a problem with rouge URLS.
    During the install we used this as the base URL - http://portalv5dev.wiley.com:8080/etc
    Our SSO set up is configured to http://devportal.wiley.com/etc
    Great we can get in but of course most of the URL's are pointing to the old address. I have changed the server settings through the admin console and also amended, n_config.xml, j_config.xml and wsserver_config.xml. Whilst this change has not caused any problems the URL's still haven't been amended.
    Has anyone had any success in changing this, if so could you shed some light. Many thanks, Adam

    How do you map your corporate user directory and EBS users? Is there any way to guarantee that users have the same credentials? Suggest you to forward the query to Portal and Security forum so that security experts can also have their opinion. Don't think it will work without partner application registration.

  • How to get the URL of the request.

    I am trying to get the URL from where the request is coming to the servlet. If http://www.xx.com/ calls my servlet i want to know that the request is coming from http://www.xx.com/ URL. If i use request.getRequestURL() which is displaying my servlet URL. Please help me which is very urgent.

    You actually want the referrer? You can obtain it from the request headers as follows:String referrer = request.getHeader("referer"); // Yes, with the legendaric misspelling in there.Having said that, be aware that the client has full control over what he sends with the request headers. So the client can change/spoof/remove the referrer entry to his taste anytime. Your code should not rely that much on it, it should rather be used for statistics only.

  • BSP Exception: Access to URL /irj/servlet/prt/portal/prtroot/com.sap.ip.bi.web.portal.integration.launcher;jsessionid= not allowed

    Dear all,
    I've created out BI system in our new Portal installation and tested the connection. Everything works fine. I added the certificate of the portal to STRUSTSSO2 in BI ABAP and assigned SAP_ALL and SAP_NEW to my Account.in BI. If I open the iView from the portal I get a BSP Exception with the message:
    The used connection by the iView is to the ABAP-Stack of the BI-system not to the JAVA-Stack. Is that correct?
    BSP Exception: Der Zugriff auf die URL /irj/servlet/prt/portal/prtroot/com.sap.ip.bi.web.portal.integration.launcher;jsessionid=IDBYatWIpt_pX4uc52ChoZqMWkm1RAFW2qsA_SAP ist untersagt.
    What can be the problem/reason?
    Thanks!

    Hi Gerrit
    In both places you have to provide a authorization access to the end users then only it will work. because your are already said that in SAP_All & SAP_New working fine
    Back end BI system access as per the word document as pasted the link
    https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=7&cad=rja&uact=8&ved=0CFIQFjAG&url=http%3A%2F%2Fbasisdsp.f…
    For SAP portal you have to create iview's assign the same to end user
    Assigning an Authentication Scheme to an iView - User Authentication and Single Sign-On - SAP Library
    Portal Authentication Infrastructure - Configuring the Portal for Initial Use - SAP Library
    BR
    SS

  • How to get the URL of an iView using AbstractPortalComponent

    Hi All,
    I need to get the URL of an iView using AbstractPortalComponent using the following code.
    But i am unable to open the URL from the Browser
    This is the following code snippet
    public class AbsClass extends AbstractPortalComponent
        public void doContent(IPortalComponentRequest request, IPortalComponentResponse response)
    IPortalComponentURI componentURI = request.createPortalComponentURI();
    componentURI.setContextName("pcd:portal_content/LOG_Viewer/LogViewer");
    String URI=componentURI.toString();
    response.write(URI);
    The output i got from the browser is:
    /irj/servlet/prt/portal/prtroot/pcd!3aportal_content!2fLOG_Viewer!2fLogViewer
    Actual Path: pcd:portal_content/LOG_Viewer/LogViewer
    Output Path: /irj/servlet/prt/portal/prtroot/pcd!3aportal_content!2fLOG_Viewer!2fLogViewer
    Why some extra numerics are embeded in the output path when compare with the Actual Path.
    Can any one send me the modified code and your suggestions, how to achieve this problem.
    Regards
    Phani

    Hi,
    Now i need to get the URL of this component.
    IPortalComponentRequest request = (IPortalComponentRequest) this.getRequest();
    IPortalComponentURI componentURI = request.createPortalComponentURi();
    componentURI.setContextName("com.sap.portal.appintegrator.sap.bwc.Transaction");
    String URI=componentURI.toString();
    response.write(URI);
    I export this component into Portal and i tested with an iView based on this par file, i got the URL in the Preview.
    But when i tried to run this URL by adding the http://<IPADDRESS>:<PORTNO>+URL
    I am facing one AccessDenied Exception for this Object. ( USER/GUEST)
    Is there any security zone, or other Permissions Problem, if so can you plz guide me what are the settings i have to change inorder to resolve this exception
    Regards
    Phani

Maybe you are looking for

  • Want to format hard drive and start over but do not have original disks

    Hey guys I want to format my hard drive however I messed up my mac partition and also I do not have my original install disks so I can not do it either. The only working OS i have is Windows right now. how can I format the drive and instal an OS X. I

  • How to maintain variants in a report?

    how to maintain variants in a report?

  • Frm-90928 positional parameter after key on command line

    frm-90928 positional parameter after key on command line I have an error while i run form module. i am using database 9i with 9iDS. Plz help me to resolve this issue.

  • Bugs in Premiere Pro CC 2014 (8.0)

    I'm going to file bug reports but just wanted to see if anyone else is having these problems... • setting poster frames - whenever I set a poster frame the chosen frame doesn't stick • video & audio preview folder location - I have my scratch disk fo

  • Best Approach for Content Migration tp UCM

    Hi, We are migrating to UCM. It is about 80% of web content and 20% static files. And we have about 30k Content items. Please suggest various approaches for this and please do suggest the best one that will suite the above requirement. Thank you...