Can I use servlet as my welcome file

How can I use servlet as my welcome file? I know how to use jsp or html pages as my welcome file but that doesn't work for servlets. I modified my web.xml for making jsps and html as my welcome pages but that <welcome-file-list> tag is not working for servlets.

This was a bug that occured in older Tomcat programs, not sure if it still occurs or not.
Basically, when this happens, you have to have a physical file with the welcome file name. So you would have to create a file named index.do in each of your directories you wanted the welcome to work for. The index.do wouldn't have to actually do anything. It just had to exist. Then when the URL was used to create content, the servlet would be called to create that content.

Similar Messages

  • Servlet as a welcome file: is it a myth?

    Hello
    There are many articles on the web that espouse that Servets 2.4 allow for a servlet to be specified as a welcome file thusly (taken from OnJava.com):
    First, register the servlet in web.xml.
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <web-app xmlns="http://java.sun.com/xml/ns/j2ee"
    xmlns:xsi=
    "http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=
    "http://java.sun.com/xml/ns/j2ee
    http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4">
    <servlet>
    <servlet-name>MyServlet</servlet-name.
    <servlet-class>com.jspservletcookbook.MyServlet</servlet-class>
    </servlet>
    <!-- optionally map the 'MyServlet' servlet to a URL pattern -->
    <servlet-mapping>
    <servlet-name>MyServlet</servlet-name>
    <url-pattern>/myservlet</url-pattern>
    </servlet-mapping>
    <!-- rest of web.xml ... -->
    Then create a welcome-file element in web.xml that specifies the registered servlet name.
    <welcome-file-list>
    <welcome-file>MyServlet</welcome-file>
    <welcome-file>default.jsp</welcome-file>
    </welcome-file-list>
    Make sure to use the servlet name in the welcome-file element without a forward slash (/) preceding it.
    Poppycock I say. At least it's not working for me with either Tomcat 5 or Tomcat 5.5. Has anyone out there ever seen this work on Tomcat?

    It most certainly is possible now, but wasn't until rather late in TC 5.0.xx series I believe (5.0.18 or so?). You can chack the change logs to id exactly when...
    But the reason it isn't working for you is you have to match the value in your <welcome-file> to the URL in the servlet's <url-pattern> servlet mapping. So your web XML should look like this:
    <servlet>
      <servlet-name>MyServlet</servlet-name.
      <servlet-class>com.jspservletcookbook.MyServlet</servlet-class>
    </servlet>
    <servlet-mapping>
      <servlet-name>MyServlet</servlet-name>
      <url-pattern>/myservlet</url-pattern>
    </servlet-mapping>
    <welcome-file-list>
      <welcome-file>myservlet</welcome-file>
      <welcome-file>default.jsp</welcome-file>
    </welcome-file-list>Your porblem was case. Your url-pattern had lower case, but the welcome-file had upper case letters like the servlet name.
    Here is an example app that I tested and worked:
    //The servlet:
    package net.thelukes.steven;
    import java.io.IOException;
    import java.io.PrintWriter;
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    public class WelcomeServlet extends HttpServlet {
         public void doGet(HttpServletRequest request, HttpServletResponse response)
           throws ServletException, IOException {
              PrintWriter out = response.getWriter();
              out.println("Hello World");
              out.flush();
              out.close();
    //the web.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <web-app id="WebApp_ID" version="2.4"
             xmlns="http://java.sun.com/xml/ns/j2ee"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
                                 http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
         <display-name>WTPTest</display-name>
         <servlet>
              <servlet-name>Welcome</servlet-name>
              <servlet-class>net.thelukes.steven.WelcomeServlet</servlet-class>
         </servlet>
         <servlet-mapping>
              <servlet-name>Welcome</servlet-name>
              <url-pattern>/welcome</url-pattern>
         </servlet-mapping>
         <welcome-file-list>
              <welcome-file>welcome</welcome-file>
         </welcome-file-list>
    </web-app>
    //The address I typed (the web app is names WTPTest
    http://localhost:8080/WTPTest
    //The HTML Output
    Hello World

  • After upgrading to Mountain Lion, I cannot open my File Maker Pro files. Can I use Numbers to open these files?

    After upgrading to Mountain Lion, I cannot open my File Maker Pro files. Can I use Numbers to open these files?

    Numbers is a spreadsheet program and FileMaker is a database program, so you probably can't use Numbers to open them unless you had first exported them from FileMaker in a spreadsheet-compatible format.
    If you upgraded from 10.6 Snow Leopard or earlier and your old copy of FileMaker won't open anymore, it might be a PowerPC application that is not compatible with 10.7 and later. If that is the case, to work with your FileMaker files you should upgrade your copy of FileMaker to the latest version, which seems to be FileMaker 12.

  • How can I use Applescript to copy a file's icon to the clipboard?

    Hello,
    How can I use Applescript to copy a file's icon to the clipboard?
    Thanks.
    Lennox

    there is no way to do that that I know of. but you can extract an icon of a file to another file using command line tool [osxutils|http://sourceforge.net/projects/osxutils]. you can then call the relevant command from apple script using "do shell script".

  • How can I using functions implicit in dll file in java code ?

    How can I using functions implicit in dll file in java code ?
    I'm developing a program that interfacing with fingerprint hardware.
    I have the finger print already, and I have to the SDK that have all functions for managing this fingerprint.
    These SDK functions are represented in dll files.
    I want to know how can I use these functions in java code .
    I looked on this link of sun forums :
    http://forum.java.sun.com/thread.jspa?threadID=305171&messageID=1215613
    but I don't Understand the meaning of native code.
    Thanks for help.

    please please please please please please please please help me:
    After reading a lot of articles, tutorials, and overviews about JNI (Java Native Interface)
    I found that these steps
    1.     Develop the Java code
    2.     Compile the Java code to a class file
    3.     Generate the header file
    4.     Implement the native method
    5.     Create the shared library or DLL
    6.     Run the Java program
    Is the common steps in JNI development
    The most powerful link was
    http://java.sun.com/docs/books/jni/html/start.html
    and
    http://www.netbeans.org/kb/55/beginning-jni-part2.html
    and the pdf oh this link
    http://www.ibm.com/developerworks/edu/j-dw-javajni-i.html requiring IBM registration to download it.
    But I have already the DLL, and want to the stright forward way to use its functions by java code only.
    I don not to write any C++ code .
    Is this possible???????????????????????????????
    The name of these dll is �zkemsdk.dll�
    It developed by ZKSOFTWARE company for managing a finger print �NP1500A�of
    http://www.napcogulfsecurity.com/finger_print.asp
    thanks for help

  • Can I use Migration Assistant to Copy files from one mac to another, but not delete the original files off of the original Mac?

    I just purchased a new Macbook Pro Retina, and I have an old Macbook Pro w/o Retina and wish to use migration assistant. I still want to use the older Macbook Pro and keep all the files on it, but copy them and also put them on my new Macbook. What I'm trying to say is, can I use migration assistant to move files to a new Mac, while keeping the files on the old computer?

    You can omit some broad categories, but you can't pick and choose individual items.
    See Using Setup Assistant on Mountain Lion or Lion (preferred method), or the similar Using Migration Assistant on Mountain Lion or Lion for the gory details.

  • Using servlet to generate XML file

    What I want to do is simple but can't work. Hope you guys can give me a hint.
    I succesfully generate XML file in command line using Oracle XML parser and class generator. Then I was trying to do it using servlet. it compiles fine but generate NullPointer exception at the line:
    Emp e1= new Emp(); //Emp is the root of XML
    I suspect the Emp constructor can't correctly find the globalDTD in its superclass -CGDocument. Please note this only happens in servlet setting, not is command line setting. Any suggestion to get arounf this?
    Another unrelated question is that when I create a XML file using the Oracle XML parser, it seems all the elements a file has to be added once, otherwise the compiler will compalain about the missing element. this will be inconvinient when I constructing a big XML file, which I 'd liek to split into small piece and add them up. Maybe there is a good way but I just don't know it.
    my email: [email protected]

    Hi,
    I'm running into the same problem deploying the classes generated by the class generator. Code works fine from JDeveloper, but had to put my DTD in the directory where my classes are. Deploying the classes with Apache's JServ gives me a NullPointer exception on the first addNode method. I guess it can't find the DTD. I tried to put the DTD in many locations but this didn't fix the problem. Any suggestions?
    Steve,
    Did you fix this problem? Thanx!
    null

  • How can i Use SERVLET with RMI to avoid trust certificate

    I know that for begining RMI, you must launch the server and the client.
    for the server i use :
    java -Djavax.net.ssl.trustStore=server.keystore -Djavax.net.ssl.keyStore=server.keystore -Djavax.net.ssl.keyStorePassword=server TestServer
    for the client I use :
    java -Djavax.net.ssl.trustStore=client.keystore -Djavax.net.ssl.keyStore=client.keystore -Djavax.net.ssl.keyStorePassword=client TestClient
    and all work fine.
    but i want to use a servlet for rmi client and i wrote this:
    public class AppelServlet extends HttpServlet
         public void doPost(HttpServletRequest request, HttpServletResponse response)
         throws ServletException, IOException
              try
                   System.out.println("Registering secure RMI socket factory ...");
                   java.rmi.server.RMISocketFactory.setSocketFactory(new SecureRMISocketFactory());
              TestRemote test = (TestRemote) Naming.lookup("rmi://127.0.0.1:7123/TestClient");
    String reponse=test.toLowerCase("HELLO WORLD");
                   System.out.println("la reponse est : "+reponse);
         catch (Exception e)
              System.out.println("test client exception: " +e);
    PrintWriter out = response.getWriter();
              response.setContentType("text/html");
    and i have the following error on tomcat:
    Registering secure RMI socket factory ...
    test client exception: java.rmi.ConnectIOException: error during JRMP connection
    establishment; nested exception is:
    javax.net.ssl.SSLHandshakeException: Couldn't find trusted certificate
    i think i must precise how to indicate the truststore like in the first case.
    help me please.
    hamdi

    Hi,
    Try doing the following steps.
    Assuming you have a certificate obtained
    Export the certificate into a .cer file.
    On IE, goto tools->internet options->content->certificates, and export to a .cer file.
    Using keytool of java import the certificate to the store that can be used doing the following command.
    keytool -import -alias <ailas> -file < .cer filename> -keystore <storename here>
    set the javax.net.ssl.trustStore and javax.net.ssl.trustStorePassword properties at the command prompt using the command below.
    java -Djavax.net.ssl.trustStore=<storename> -Djavax.net.ssl.trustStorePassword=<password> <classname>
    Let me know if this helped.
    Also take a look at this link for using RMI with SSL
    http://java.sun.com/products/jdk/1.2/docs/guide/rmi/SSLInfo.html
    Regards,
    Roopasri Vittal
    Developer Technical Support
    Sun Microsystems
    http://sun.com/developers/support

  • File download using servlet and jsp. File Dialog comes twice

    Hi
    I was trying to download a file using servlet. There is a link which calls the servlet. When I click on the link file dialog box comes up. On selecting Open it again shows me the file dialog box. I changed the method from POST to GET and it worked properly.
    My question is why does it work with GET and not with POST. I am aware of the differences between POST and GET but am not able to come to a rational explanation for this behaviour.
    Please if anyone can explain this to me I am going crazy thinking an answer for this.
    Thank you.
    Regards
    Jay

    Hi Jay,
    I also have the same question. Why does it work with GET and not for POST?. If you were able to find the answer please let me know.
    Thank you.
    Regards,
    Aravind

  • Can I use my Nikon D90 AVI files in Premiere Pro CC on my iMac?

    Hi and thanks in advance to anyone who can lend me a hand. I am new to both Premiere Pro CC and Macs. I have used my Nikon D90 AVI files before with Premiere Elements on my PC with no problem, but the same films aren't working on my new setup with Premiere Pro CC and an iMac.
    I can see and preview the films in the Source window but when I try to drag them onto the sequence window I get a little hand with a "no" sign.
    I am using a version 7.1.0 (141) of PP CC and am on OS X 10.9
    Do I need to transcode the files? If so, to what? And what is the best way to do that?
    Many many thanks for any help!

    Just remember, you will not always get the answer you want right away. Some people will point you to tutorials, some, like me, will attempt to help and still point you to tutorials, and some will just answer the question as best they can.
    Some might insult you, and some merely insult your intelligence. Don't be offended. Do, however, search the forums as best you can in an attempt to find the answer before you post.
    I realize that people don't always have the right words to describe the problem, and therefore have trouble searching. If searching fails you, just ask. It generally works out in the long run. And as you have discovered, sometimes a combination of posts may do the trick.

  • Can I use Time Machine to back files on an External Hard Drive

    My MacBook Pro hard drive filled up with movies, pictures, and music, so I bought a 2TB Time Capsule.  I have a external hard drive that is about the same capacity as my MacBook hard drive. Sine the Time Capsule is by far the largest drive I have, I moved all my movies, music, and pictures to the Time Capsule and am using it as an external hard drive.  I attached a 500GB external hard drive to the Time Capsule and I use that as the backup drive for Time Machine. However, the problem I am encountering is that I can't seem to direct Time Machine to include all of my files on my Time Capsule in the back up on to the other external hard drive. 
    Can I use Time Machine to backup data that I store on my Time Capsule to a external hard drive?  If not, what is hte best method for backing up my files that are on my Time Capsule?
    Thanks,
    David

    You need to use a different utility .. eg CCC or Chronosync to backup from the TC to yet another drive.. the problem is, that drive should be connected to the computer.. if you use a USB drive on the TC.. the file copying will be slow as slow as you will not believe.. all files are copied to the computer, then back to the TC.. it cannot copy directly to the TC..
    As Neil said.. one way or another you need to use an external drive on the computer, even if you don't use it all the time.. the danger of course is not doing regular backups.. and forgetting their importance.
    A true NAS will have automated backup incrementally of the files stored.. The TC is not a NAS in that sense.. it is a backup target for TM above and beyond anything else.

  • How can I use regular expression to open files of certain types in java?

    Ok this is the problem I am facing:
    I have a command line input of something like "/usr/foo/bar/*.html"
    and there are multiple files in that folder that end with .html.
    How can I use the input to go through/open all the .html files in Java?
    Help would be greatly appreciated thanks!

    Or if you have to do it in java, check out the interfaces java.io.FileFilter and java.io.FileNameFilter
    http://home.tiscali.nl/~bmc88/java/sbook/0128.html
    class HTMLFilter implements FilenameFilter {
        public boolean accept(File dir, String name) {
            return (name.endsWith(".html"));
    }Cheers,
    evnafets

  • Can't use procedure in the .rdl file.

    Hi experts,
    I created a simple River project, and I can active the project successfully.
    But when i added some codes to call a procedure, then i can't active the rdl file.
    This is the code I used to call a procedure:
    action callExternalProc2() : DecimalFloat[]
          let x  = sap.hana.catalog.RIVERPRJ.MY_PROCEDURE_TEST3();
          return x;
    The error message met when active the project is:
    A transaction rollback may have left the object in an inconsistent state.
    exception 40183:
    repository/base/activation/activator.cpp:884
    Transaction rollback detected. Activation failed.
    When i commented the above codes, the activation will be successful.
    And the procedure can execute in SQL console.
    Can you give me some suggestions?

    Hi Omer,
    I tried to create my stored procedure in another schema(owned by my user), but I still can't active the rdl file.
    Also, I can't execute the following sql statement using my user or the system user:
           set schema "RIVERPRJ";
           grant execute on MY_PROCEDURE_TEST3 to _SYS_REPO with grant option;
    The error message is:
         Could not execute 'grant execute on MY_PROCEDURE_TEST3 to _SYS_REPO with grant option' in 10 ms 659 µs .
         SAP DBTech JDBC: [258] (at 17): insufficient privilege: Not authorized to grant the privilege on the procedure: line 1 col 18 (at pos 17)
    If I active the rdl file, the error message is as follows:
    In the procedure, if I do some queries from the tables created by the rdl, it did not work, but it works if I do some queries from the tables which were not created by the rdl file.
    I think this maybe the reason for the error message "A transaction rollback may have left the object in an inconsistent state." .
    In my opinion, I think we can not use a stored procedure that do some queries from tables created by the rdl entities.
    Because create the entity and call the procedure at the same time may left the object in an inconsistent state.
    Put the queries in an action is ok, but the river can not support some key words like "lag over",.
    So i am trying to put these things in a procedure and call it in the action.
    If  we can't use procedure, how could I use some sql key words like "lag over"?
    Could you give me some suggestions?
    Thanks very much for your help.
    Regards
    Eric

  • How can I use a manually created help file

    Is it possible to use a manually crated help file *.hlp (microsoft help file) in a oracle forms application.
    I want to open the help file from in my help menu. How can I do that??
    Joury

    Hi,
    Have you tried WIN_API_SHELL.winhelp and WIN_API_SHELL.winhelpex?
    Both are available in D2KWUtil.PLL, usually included in Forms demos.
    Pedro
    null

  • Can i use this line in JNLP file?

    Can i use the below line in JNLP file?
    <property name="ondc.root" value="@user.dir"/>
    I want to get the client side location of a JAR file. How can i get it?
    plz help
    Thanks,
    Deepak

    I Think u can not use this line
    as i have studied jnlp file syntax thoruoghly and did not found any thing like this
    would u plz telll me what u want to aceive so that i can suggest u any solution.
    Regards
    M Fazal Ur Rehman(Pakistan)

Maybe you are looking for