Getting the servlet alias programatically

Does anyone know if there is a way to specify the servlet's alias in the same way that one can find the context with request.getContextPath()? It seems a pity to have to hard code the alias name?
Thanks.

Maybe this could help
Variables as found in Perl (I think) and Servlet EquivalentPATH_INFO          =              request.getPathInfo()
PATH_TRANSLATED  =     request.getPathTranslated()
SCRIPT_NAME        =          request.getServletPath()

Similar Messages

  • How can I get the servlet Context from a WebService Implementation?

    I have made a webservice endpoint, using the conventional way (WSDL->wsimport->Java interface->implementation) . I need to get the servlet context below the implementation class. I haven't found any way to get the servletContext though. Any clues? Any help will be greatly appreciated.

    yes  i can found the words's unicode form Cmaps where may be at the type of tounicde and another Cmaps table just like "Adobe-GB1-GBK-EUC" ,but when the word dont have either of them how can i do? when i write a chinese word "一",it just the winansi encoding ,  there is not Cmap for me to use to change the "G208f" to the word "一"'s unicode value.
                   best wishes      thank you very much

  • How to get the version changes programatically in ItemCheckedin event

    Hi,
    I am creating a custom version history page.
    I have a requirement were I have to capture the changes after file check-in and display it in the custom page.
    Is there anyway to get the version changes programatically after the file has been checked-in?
    Is is possible to get the current version and previous version in ItemCheckedin event
    and get the version changes?
    Thanks in advance,
    dhijit

    Hi,
    As Dimitri said, we can use ItemCheckingIn event to achieve it.
    The following code snippet for your reference:
    public override void ItemCheckingIn(SPItemEventProperties properties)
    base.ItemCheckingIn(properties);
    int beforeLevel = (int)properties.BeforeProperties["vti_level"];
    int afterLevel= (int)properties.AfterProperties ["vti_level"];
    if((beforeLevel==255) && (afterLevel==1))
    // This is a major version that is being checked in . . .
    int majorVer= properties.ListItem.File.MajorVersion+1;
    Best Regards
    Dennis Guo
    TechNet Community Support

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

  • Error in getting the servlet response

    Below is my ErrorPage Servlet. Whenever a 404 page not found error is encountered, the error page servlet reads the 404.html, and writes the content to the response. But I am not able to see the content in IE, but works fine in mozilla.
    public class ErrorPageServlet extends HttpServlet {
        protected void doGet(HttpServletRequest request, HttpServletResponse response)
                throws ServletException, IOException {
            String errorPath = request.getAttribute("javax.servlet.error.request_uri").toString();
            int statusCode = Integer.parseInt(request.getAttribute("javax.servlet.error.status_code")
                    .toString());
            String[] errorPathSegment = errorPath.split("/");
            String site = errorPathSegment[2];
            switch (statusCode) {
            case HttpServletResponse.SC_NOT_FOUND:
                writeOutFile(request, response, "/" + site + "/error/404.html");
                break;
            case HttpServletResponse.SC_INTERNAL_SERVER_ERROR:
            case HttpServletResponse.SC_NOT_IMPLEMENTED:
            case HttpServletResponse.SC_BAD_GATEWAY:
            case HttpServletResponse.SC_SERVICE_UNAVAILABLE:
            case HttpServletResponse.SC_GATEWAY_TIMEOUT:
            case HttpServletResponse.SC_HTTP_VERSION_NOT_SUPPORTED:
                writeOutFile(request, response, "/" + site + "/error/500.html");
                break;
        public void writeOutFile(HttpServletRequest request, HttpServletResponse response,
                String fileName) throws IOException {
            ServletContext context = request.getSession().getServletContext();
            response.setContentType("text/html");
            PrintWriter writer = response.getWriter();
            InputStream resourceStream = context.getResourceAsStream(fileName);
            if (resourceStream != null) {
                InputStreamReader streamReader = new InputStreamReader(resourceStream);
                BufferedReader reader = new BufferedReader(streamReader);
                StringBuilder builder = new StringBuilder();
                for (String line = reader.readLine(); line != null; line = reader.readLine()) {
                    builder.append(line);
                    builder.append('\n');
                writer.write(builder.toString());
                writer.flush();
            } else {
                log.info("Problem occurred with " + fileName);
                response.sendRedirect("/");
        }Also attached is my 404.html
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "[http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd]">
    <html xmlns="[http://www.w3.org/1999/xhtml]">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <meta http-equiv="refresh" content="10;URL=/" >
    </head>
    <body>
    <h1>Error</h1>
    <p>A technical error has occurred. You will redirected in 10 seconds</p>
    </body>
    </html>

    Hi..
    Thanks for the comment.
    Below is how my web.xml entry looks like.
    The requirement is to send a 404 error response and that will be handled by a servlet which inturn writes the output to the response object.
         <servlet>
              <servlet-name>ErrorPageServlet</servlet-name>
              <servlet-class>com.test.ErrorPageServlet</servlet-class>
         </servlet>
         <servlet-mapping>
              <servlet-name>ErrorPageServlet</servlet-name>
              <url-pattern>/error</url-pattern>
         </servlet-mapping>
         <error-page>
              <error-code>404</error-code>
              <location>/error</location>
         </error-page>>>
    the first option to turn off the "show friendly html error pages" works fine.
    It would be better if I can get a different solution

  • How to get ther servlet name from the Httprequest / servletContext

    Hi,
    How can I get the servlet name from the Http Request / Servlet conext?
    Arthik

    I have a requirement to call the business logic either in local server / external server.
    Local / External server
    The original / main request is made to the server from the client and from the server if the main request requires some resource (second request from server side) available in the external server then I need to make a URL connection. If the requested resource is the local resource then I need to by-pass the HTTP call. So I need to verify the server name , port with the originally requested server.Then I need to check if the request servelt is available in local or not.
    Can you please help me.

  • How to determine the Servlet which current request is mapped to

    Hello folks,
    having a filter, i want to discover the servlet (if any) which will serve the current request. I want to have it before the chain execution. Does someone has an idea how to accomplish this using Servlet API? The old API provided the getServlet(String name) method for this task. Here the sample code:
    Servlet servingInstance = discoverServlerForRequest(request); //i look for implementation of this method
    chain.doFilter(request,response);I know that it would be very easy to get the servlet AFTER processing the chain, but the clue for me is to get it before.
    Maybe Tomcat has implemented some special servlet context attributes to map it?
    any hint appreciated!
    thanks

    its possible, for sure. but then I need two filters to achieve it. I'll post my solution later, if there wont be any other ideas. I know that tomcat maps many objects by attributes...maybe there is a key for it.

  • Get the current position within the PBEL Prozess

    Hi,
    In the BPELConsole I can see the the flow of every PBEL process
    instance and thus I see the current position within the process.
    How would you get the current position programatically, via SOAP e.g.?
    Kind regards,
    Martin

    Hi,
    there is a JAVA API provided by Oracle
    http://download-uk.oracle.com/docs/cd/B31017_01/integrate.1013/b28986/toc.htm
    If you really need SOAP, you can build your own Java webservices with this API

  • How to find the servlet container used via servlet

    I need to write code for different servlet container in a servlet. so I need to find in runtime what servlet container is used.
    Please let me know is there any possibility to get the servlet container name in servlet.
    Thanks & Regards,
    Nasrin.N

    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.*;
    public class Context extends HttpServlet {
    public void service(HttpServletRequest req,HttpServletResponse res) throws ServletException,IOException {
    PrintWriter out=res.getWriter();
    res.setContentType("text/html");
    ServletContext stx=getServletContext();
    out.println("ServletContext " + stx.getServerInfo());
    }

  • Can get this Servlet to Work! New Java User needs help.

    I have been using a text from New Riders to learn about creating server applications, and am using Tomcat as the server in a Windows XP environement. As per the instructions, to create a new application and path, I added the following path under the webapps directory, that sits under my Tomcat directory:
    myApps
    --WEB-INF
    ----classes
    I then create copied Java class code, listing below, and compiled, put the class in the classes directory in my new directory path. The code is simple, here it is:
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.*;
    import java.util.*;
    public class TestingServlet extends HttpServlet {
    public void doGet(HttpServletRequest request,
    HttpServletResponse response)
    throws ServletException, IOException {
    PrintWriter out = response.getWriter();
    out.println("<HTML>");
    out.println("<HEAD>");
    out.println("<TITLE>Servlet Testing</TITLE>");
    out.println("</HEAD>");
    out.println("<BODY>");
    out.println("Welcome to the Servlet Testing Center");
    out.println("</BODY>");
    out.println("</HTML>");
    I then created a file called web.xml in the WEB-INF directory, as w follows:
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <!DOCTYPE web-app
    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
    "http://java.sun.com/dtd/web-app_2_3.dtd">
    <web-app>
    <servlet>
    <servlet-name>Testing</servlet-name>
    <servlet-class>TestingServlet</servlet-class>
    </servlet>
    </web-app>
    I started the Tomcat server process, and pointed my browser to the URL http://localhost:8080/myApp/Servlet/TestingServlet. I received the following error
    type Status report
    message /myApp/Servlet/Testing
    description The requested resource (/myApp/Servlet/Testing) is not available.
    After searching some information on the web, I found some references to context information, that should be included in another file, called server.xml, that resides under the conf directory in the Tomcat root. I found it, and added the following within the "host" tags, just after the last ending /context tag, for the example directory that came with Tomcat:
    <Context path="/myApp" docBase="myApp" debug="0" reloadable="true" >
    </Context>
    I stopped and restarted the Tomcat server. This time, I checked under the Manager page of Tomcat, and found the myApp directory listed, and apparently "started", whatever that means
    pointed my browser to the URL http://localhost:8080/myApp/Servlet/TestingServlet. I still receive the following:
    type Status report
    message /myApp/Servlet/Testing
    description The requested resource (/myApp/Servlet/Testing) is not available.
    I tried one more thing. I put my class under the "examples" directory that comes with Tomcat, change the web.xml file that resides under its WEB-INF directory, and tried to see if I can get the servlet to work. And it actually does, which leads me to believe, I did something wrong setting up the directory environment in Tomcat.
    At this point I am at a loss to figure out what I did wrong, and what else I can do to fix this. Any help, suggestions, would be great.

    ok, I have got your servlet runnig on Jboss with Tomcat,
    The war file contents are
    myApp/
    META-INF/
    META-INF/MANIFEST.MF
    WEB-INF/
    WEB-INF/classes/
    WEB-INF/classes/TestingServlet.class (No package)
    WEB-INF/web.xml
    Web.xml
    <web-app>
    <servlet>
    <servlet-name>Testing</servlet-name>
    <servlet-class>TestingServlet</servlet-class>
    </servlet>
    <servlet-mapping>
    <servlet-name>Testing</servlet-name> <------- My mistake use Testing
    <url-pattern>/servlet/testing/*</url-pattern <------- lowercase S
    </servlet-mapping>
    </web-app>
    url
    http://localhost:8080/myApp/testing/blah

  • How to get the query values from the url in a servlet and pass them to jsp

    ok..this is the situation...
    all applications are routed through a login page...
    so if we have a url like www.abc.com/appA/login?param1=A&param2=B , the query string must be passed onto a servlet(which is invoked before the login page is displayed)..the servlet must process the query string and then should pass all those values(as hidden values) to the login jsp..then user enters username and pswd, then there should be another servlet which takes all the hidden values of jsp and also username and pswd, authenticates the user and sends the control back to that particular application along with the hidden values...
    so i need help on how to parse the query string from the original url in the servlet, pass it out to jsp, and then pass it back to the servlet and back to the original application...damnn...any help would be greatly appreciated...thanks

    ok..this is the situation...Sounds like you have a bad design on your hands.
    You're going to send passwords in a GET request as clear text? Nice security there.
    Why not start with basic security and work your way up?
    %

  • How to get the value from a servlet?

    Hello guys:
    how can i get the value from a servlet on my jsp page,for example return a boolean variable from a servlet
    which API to use?
    thanks

    Hi
    There is no specific API for this, call the method of the servlet which returns the required value in your JSP page.
    Thanks
    Swaraj

  • How to get the data of table from JSP to Servlet?

    Hi,
    I have a dynamic editable table of 3 columns on a jsp. On click on any cell the usr can edit the data. Now on click of submit button on the jsp I need to submit or get the whole data of all the rows to a servlet which would further process it.
    How do I do that?
    TIA.

    I am not sure whether u r getting my doubt or not
    properly. I am populating the table data in an
    arraylist of DO. with this arraylist I am displaying
    the data on the Screen.
    <%
    for(int i=0;i<alList.size();i++)
    DO d = alList.get(i);
    %>
    <Table>
    <tr>
    <td><%=d.getfirstField()%></td>
    <tr>
    </Table>
    <%
    %>
    The above code sniipet displays the data on screen.
    But as table being editable i would change the data
    in the cell and submit .
    So how do i capture this data? I cannot name the cell
    becos I am not sure how many rows would be displayed.
    In servlet I would use request.getParameter(?);
    TIAIf you table is editable nad has input field to edit then "malcolmmc's " answer will work perfectly.
    you can also use hidden form fields to use those vaues at servlet like this
    <input type="hidden" name="UniqueName' value="<%=d.getfirstField()%>'>
    Here UniqueName should be the unique for each cell value so that on servlet you can fetch these values using request.getParameter("UniqueName").

  • How can I get the real column of an alias in a view using system catalogs?

    Given a view with columns that use aliases, I would like to get the real column name for the view column with the alias.
    For example,
    CREATE VIEW myView AS
    SELECT name as col_1, price as col_2, price + 1000 as col_3
    FROM myTable
    I want to get that 'col_1' is actually the 'name' column and 'col_2' is the 'price' column by querying the system catalogs of SQL Server. It would be great to know whether I can resolve what 'col_3' is in the
    example as well (i.e., when an alias is an expression, not just a column). 
    Thanks in advance.

    Or you can use the System function
    sys.dm_exec_describe_first_result_set, example
    CREATE TABLE myTable
    (name varchar(30), price money);
    GO
    CREATE VIEW myView AS
    SELECT name as col_1, price as col_2, price + 1000 as col_3
    FROM myTable;
    GO
    SELECT name, source_table, source_column
    FROM sys.dm_exec_describe_first_result_set(N'SELECT * FROM myView', NULL, 1) AS FRS
    =>
    Olaf Helper
    [ Blog] [ Xing] [ MVP]

  • How can I get the default value of a particular preference programatically. I know I can see the default value for some of the preferences in about:config but, I need a programatic way to get the default value.

    <blockquote>Locked by Moderator as a duplicate/re-post.
    Please continue the discussion in this thread: [tiki-view_forum_thread.php?comments_parentId=702631&forumId=1]
    Thanks - c</blockquote>
    == Issue
    ==
    I have a problem with my bookmarks, cookies, history or settings
    == Description
    ==
    How can I get the default value of a particular preference in FireFox?.
    I know I can see the default value for some of the preferences in about:config but, I need a programatic way to get the default value.
    I see some that there are values for preferences in firefox.cs but I am not certain that these are being used as the default values for preferences. prefs.js in user's profile only has the updated values and not the default values.
    Any help towards acheiving this programtically is greatly appreciated.
    If the default values are stored in a file, kindly let me know the format in which it is stored for me to parse it programatically.
    == User Agent
    ==
    Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Win64; x64; Trident/4.0; .NET CLR 2.0.50727; SLCC2; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0)

    Dear Friend,
    Here when you have the callableSattement as ?=proc(?), the first ? is an output parameter. So you should register it as out parameter using registeroutparameter.
    Then you can get the value from the outparameter using callablestatement.getXXX().
    Try that way.
    For free tral versions of JDBC Drivers go to www.Atinav.com

Maybe you are looking for

  • Process Chain - Follow on dependencies to DSO Activation

    Hi, I have a Data Load Process where the start routine is dependent on DSO data that was just previously activated.  For some reason it looks like the the time before the load and the time after the DSO activation are close by just seconds.  The Data

  • Problems with iPhone 3.0 software on iPhone 3G

    I love the iPhone 3.0 software update. I just wish that Apple can fix the following problems now: 1. The phone starts to slow down, real slow, a day after the update. 2. Battery uses up like crazy, takes a much longer time to charge, and the phone ge

  • How do I fix a word doc. that turned to asterisks? Or find an earlier version of the document?

    I was typing a paper and the entire doc. turned to asterisks. Then I panicked and hit save thinking that would be beneficial. Now I only have a doc. with symbols. Is there a way to find an earlier version of the paper? I have saved it at least a doze

  • Script for saving/replacing .png´s

    For Photoshop CS5: Hi, I need a script, which allows me to take the .png file i am working on, and save and replace it in the existing location with the exact same name: Without creating the "copy.png" string and preferebly without have to choose "In

  • OBIEE LDAP

    Hi, I have successfully integrated OBIEE with LDAP. I have created an initialization Block called Authentication in which I am using LDAP to authenticate users. Users are able to login to Answers. However, if I create another initialization block to