Cannot get RequestDispatcher for the first request

Hi everybody,
I've a servlet which after doing some processes, will forward to another jsp page. I found that the first request of this servlet after Tomcat is restarted always fail -- a blank page is returned instead of the target jsp page of the forward method.
Below is my code:
RequestDispatcher rd = null;
rd = request.getRequestDispatcher('target.jsp');
if (rd != null) {
rd.forward(request, response);
else {
System.out.println('rd is NULL!!??');
A blank page is returned because the request.getRequestDispatcher('target.jsp') method returned null and I did not print any output in this case. But the servlet (forward method) works fine for the second or later requests.
I suspected that the first call of request.getRequestDispatcher('target.jsp') returns null is because the target.jsp is not loaded into the servlet container yet. Am I right? If this is the case, is there anything that I can do to solve it?
The Tomcat I am using is version 4.1.27
Many thanks.

Hi tolmank,
It works now, thank you very much. But I still don't understand why, can you explain it to me please.
Thanks

Similar Messages

  • I am getting this for the first time when i sync .iphone 3gs error message itunes could not sync calendars to the iphone because the sync server failed to sync iphone

    i am getting this for the first time when i sync .iphone 3gs error message itunes could not sync calendars to the iphone because the sync server failed to sync iphone

    I have tried the suggestion to reset the sync log to no avail. Anyone have another idea? This just started after I downloaded 4.3.5.

  • Getting Connected for the First Time with JDBC

    Hello everyone. I am trying to make my first database connection to a mysql database with Java. I am using jdk 1.5.0, MySQL 4.1.11 nt, and I think I have the freshly downloaded driver C:\jdk1.5.0\jre\lib\ext\mysql-connector-java-3.0.16-ga-bin.jar" installed in the right spot. When I try to run the following code...
    package dbfinder;
    import java.sql.*;
    import javax.sql.*;
    import com.sun.rowset.JdbcRowSetImpl;
    import javax.sql.rowset.JdbcRowSet;
    import java.sql.ResultSetMetaData;
    * <p>Title: </p>
    * <p>Description: </p>
    * <p>Copyright: Copyright (c) 2005</p>
    * <p>Company: </p>
    * @author not attributable
    * @version 1.0
    public class DatabaseConnector {
    public DatabaseConnector() {
    public static void main(String args[]){
    Connection connection;
    Statement statement;
    // ResultSet resultSet;
    // ResultSetMetaData metaData;
    String DATABASE_DRIVER = "com.mysql.jdbc.Driver";
    String DATABASE_URL = "jdbc:mysql://localhost/state_crime";
    String USER = "cis695d";
    String PASSWORD = "cis695d";
    JdbcRowSet rowSet = new JdbcRowSetImpl();
    try {
    Class.forName(DATABASE_DRIVER); // load database driver
    System.out.println("class loaded");
    rowSet.setUrl("DATABASE_URL");
    rowSet.setUsername(USER);
    rowSet.setPassword(PASSWORD);
    rowSet.setCommand("Select * FROM state_crime_rates");
    rowSet.execute();
    ResultSetMetaData metaData = rowSet.getMetaData();
    int numberOfColumns;
    numberOfColumns = metaData.getColumnCount();
    System.out.println(numberOfColumns);
    } catch(SQLException sqlException){
    sqlException.printStackTrace();
    System.exit(1);
    catch(ClassNotFoundException classNotFound){
    classNotFound.printStackTrace();
    System.exit(1);
    I get the following exception...
    java.sql.SQLException: No suitable driver
         at java.sql.DriverManager.getConnection(DriverManager.java:545)
         at java.sql.DriverManager.getConnection(DriverManager.java:171)
         at com.sun.rowset.JdbcRowSetImpl.connect(JdbcRowSetImpl.java:618)
         at com.sun.rowset.JdbcRowSetImpl.prepare(JdbcRowSetImpl.java:630)
         at com.sun.rowset.JdbcRowSetImpl.execute(JdbcRowSetImpl.java:526)
         at dbfinder.DatabaseConnector.main(DatabaseConnector.java:44)
    Does anyone have any ideas? Is it my code? Is there a different driver I should use? Any help would be greatly appreciated.

    Hello everyone. I am trying to make my first
    database connection to a mysql database with Java. I
    am using jdk 1.5.0, MySQL 4.1.11 nt, and I think I
    have the freshly downloaded driver
    C:\jdk1.5.0\jre\lib\ext\mysql-connector-java-3.0.16-ga
    -bin.jar" installed in the right spot. You shouldn't be putting that JAR in jre/lib/ext, even if you've found some docs to tell you to do it. Only language extensions (e.g., packages that begin w/javax) belong there.
    I get the following exception...
    java.sql.SQLException: No suitable driver
    Does anyone have any ideas? Is it my code? Is there
    a different driver I should use? Any help would be
    greatly appreciated.The driver is correct. The class loader found it, even though I think you should use the -classpath option to find the JAR.
    It's your code.
    What are you doing with all that RowSet stuff?
    This works. Study it:
    import java.sql.*;
    import java.util.*;
    * Command line app that allows a user to connect with a database and
    * execute any valid SQL against it
    public class DataConnection
        public static final String DEFAULT_DRIVER   = "sun.jdbc.odbc.JdbcOdbcDriver";
        public static final String DEFAULT_URL      = "jdbc:odbc:DRIVER={Microsoft Access Driver (*.mdb)};DBQ=c:\\Edu\\Java\\Forum\\DataConnection.mdb";
        public static final String DEFAULT_USERNAME = "admin";
        public static final String DEFAULT_PASSWORD = "";
        public static final String DEFAULT_DRIVER   = "com.mysql.jdbc.Driver";
        public static final String DEFAULT_URL      = "jdbc:mysql://localhost:3306/hibernate";
        public static final String DEFAULT_USERNAME = "admin";
        public static final String DEFAULT_PASSWORD = "";
        /** Database connection */
        private Connection connection;
         * Driver for the DataConnection
         * @param command line arguments
         * <ol start='0'>
         * <li>SQL query string</li>
         * <li>JDBC driver class</li>
         * <li>database URL</li>
         * <li>username</li>
         * <li>password</li>
         * </ol>
        public static void main(String [] args)
            DataConnection db = null;
            try
                if (args.length > 0)
                    String sql      = args[0];
                    String driver   = ((args.length > 1) ? args[1] : DEFAULT_DRIVER);
                    String url      = ((args.length > 2) ? args[2] : DEFAULT_URL);
                    String username = ((args.length > 3) ? args[3] : DEFAULT_USERNAME);
                    String password = ((args.length > 4) ? args[4] : DEFAULT_PASSWORD);
                    System.out.println("sql     : " + sql);
                    System.out.println("driver  : " + driver);
                    System.out.println("url     : " + url);
                    System.out.println("username: " + username);
                    System.out.println("password: " + password);
                    db = new DataConnection(driver, url, username, password);
                    System.out.println("Connection established");
                    Object result = db.executeSQL(sql);
                    System.out.println(result);
                else
                    System.out.println("Usage: db.DataConnection <sql> <driver> <url> <username> <password>");
            catch (SQLException e)
                System.err.println("SQL error: " + e.getErrorCode());
                System.err.println("SQL state: " + e.getSQLState());
                e.printStackTrace(System.err);
            catch (Exception e)
                e.printStackTrace(System.err);
            finally
                if (db != null)
                    db.close();
                db = null;
         * Create a DataConnection
         * @throws SQLException if the database connection fails
         * @throws ClassNotFoundException if the driver class can't be loaded
        public DataConnection() throws SQLException,ClassNotFoundException
            this(DEFAULT_DRIVER, DEFAULT_URL, DEFAULT_USERNAME, DEFAULT_PASSWORD);
         * Create a DataConnection
         * @throws SQLException if the database connection fails
         * @throws ClassNotFoundException if the driver class can't be loaded
        public DataConnection(final String driver,
                              final String url,
                              final String username,
                              final String password)
            throws SQLException,ClassNotFoundException
            Class.forName(driver);
            this.connection = DriverManager.getConnection(url, username, password);
         * Get Driver properties
         * @param database URL
         * @return list of driver properties
         * @throws SQLException if the query fails
        public List getDriverProperties(final String url)
            throws SQLException
            List driverProperties   = new ArrayList();
            Driver driver           = DriverManager.getDriver(url);
            if (driver != null)
                DriverPropertyInfo[] info = driver.getPropertyInfo(url, null);
                if (info != null)
                    driverProperties    = Arrays.asList(info);
            return driverProperties;
         * Clean up the connection
        public void close()
            close(this.connection);
         * Execute ANY SQL statement
         * @param SQL statement to execute
         * @returns list of row values if a ResultSet is returned,
         * OR an altered row count object if not
         * @throws SQLException if the query fails
        public Object executeSQL(final String sql) throws SQLException
            Object returnValue;
            Statement statement = null;
            ResultSet rs = null;
            try
                statement = this.connection.createStatement();
                boolean hasResultSet    = statement.execute(sql);
                if (hasResultSet)
                    rs                      = statement.getResultSet();
                    ResultSetMetaData meta  = rs.getMetaData();
                    int numColumns          = meta.getColumnCount();
                    List rows               = new ArrayList();
                    while (rs.next())
                        Map thisRow = new LinkedHashMap();
                        for (int i = 1; i <= numColumns; ++i)
                            String columnName   = meta.getColumnName(i);
                            Object value        = rs.getObject(columnName);
                            thisRow.put(columnName, value);
                        rows.add(thisRow);
                    returnValue = rows;
            else
                int updateCount = statement.getUpdateCount();
                returnValue     = new Integer(updateCount);
            finally
                close(rs);
                close(statement);
            return returnValue;
         * Close a database connection
         * @param connection to close
        public static final void close(Connection connection)
            try
                if (connection != null)
                    connection.close();
                    connection = null;
            catch (SQLException e)
                e.printStackTrace();
         * Close a statement
         * @param statement to close
        public static final void close(Statement statement)
            try
                if (statement != null)
                    statement.close();
                    statement = null;
            catch (SQLException e)
                e.printStackTrace();
         * Close a result set
         * @param rs to close
        public static final void close(ResultSet rs)
            try
                if (rs != null)
                    rs.close();
                    rs = null;
            catch (SQLException e)
                e.printStackTrace();
         * Close a database connection and statement
         * @param connection to close
         * @param statement to close
        public static final void close(Connection connection, Statement statement)
            close(statement);
            close(connection);
         * Close a database connection, statement, and result set
         * @param connection to close
         * @param statement to close
         * @param rs to close
        public static final void close(Connection connection,
                                       Statement statement,
                                       ResultSet rs)
            close(rs);
            close(statement);
            close(connection);
    }%

  • The get messages function only works for the first account

    regardless of which account is listed in any order, the get messages button only gets messages for the first account in the list, thus if you are expecting one into another account you have to highlight that account and click the get messages....

    I have no idea what your talking about. Thunderbird has no apps.
    Perhaps your talking of add-ons. If you found an add-on perhaps you could mention what it is, so that I and other might know it exists.
    You appear to be under some misconceptions,
    !. Moderation is about answering questions. Wrong. Moderation is about deleting questions, editing comments that do not meet the guidelines for the forum and banning users.
    2. Searching add-on is someone elses job.
    3. Someone is getting paid to accept your criticism. I am not.
    If I as a fellow user an ignorant of an add-on then tough luck for those I advise. They should have been resourceful enough to search for add-ons before they asked the question. I can only tell people what I know.

  • For the first time, I'm trying to use adobe premiere elements10 that came with my pc Windows 8. I created a single project, saved it but cannot open it. My pc shows the file I created but I get an error message that says this type file is not supported or

    For the first time, I'm trying to use adobe premiere elements 10 that came with my pc Windows 8. I created a single project, saved it but cannot open it. My pc shows the file I created but I get an error message that says this type file is not supported or the codex is not installed. As a test, I created another very small project and get the same error message, when I try to open it. Pls give me a simple answer, a refund or a phone

    mike frischenmeyer
    What computer operating system is your Premiere Elements 10 running on? And, what video card/graphics card does that computer use?
    Is this the first time you are using Premiere Elements 10 or have you worked with it before successfully? There is no easy solution until we
    know the details and troubleshoot to determined what caused the problem.
    1. Can you open a new project?
    2. After you saved/closed the problem project, did you move, delete, or rename any of the files/folder that were related to the source media
    for that project?
    3. Please review the Adobe document on troubleshooting damaged projects.
    Troubleshoot damaged projects | Adobe Premiere Elements
    4. What are the steps that you are using to reopen this saved closed project.
    a. File Menu/Open Project/Name of Project
    b. Other
    Please review and consider and then we can decide what next based on your further details and results..
    Thank you.
    ATR

  • I clicked on iMessage on my Macbook Pro today for the first time, and now NOTES keeps opening up every 5 seconds, with a new note.  I cannot stop it from opening. If I close it or force close, it opens again in 5 seconds.  I can't get rid of it.  I have

    I clicked on iMessage on my Macbook Pro today for the first time, and now NOTES keeps opening up every 5 seconds, with a new note.  I cannot stop it from opening. If I close it or force close, it opens again in 5 seconds.  I can't get rid of it.  I have tried to clear out the iMessage settings I had put in, and I've tried to adjust the Accounts to not include notes to synch.  But, Notes will not stop.  It opens a new note, and even if you ignore it, it assumes preference every 5 seconds, and the Mac is impossible to use.

    Do you have any Boot Camp or other secondary partitions set up on your system? If so then try running a disk verification routine (chkdsk, etc.) in Windows to repair the disk. While I've not heard of it happening recently, in the past errors in these partitions have resulted in stubborn ghost files appearing in OS X.

  • When connecting my iphone 4 to itunes for the first time i get the following message "cannot connect to this device because Apple Mobile Service is not started" what does this mean and how do I solve it?

    when connecting my iphone 4 to itunes for the first time i get the following message "cannot connect to this device because Apple Mobile Service is not started" what does this mean and how do I solve it?

    I'd start with the following document with that one:
    iPhone, iPad, iPod touch: How to restart the Apple Mobile Device Service (AMDS) on Windows

  • I have a Macbook pro that I bought in 2008. I recently installed Maverick. For the first time, I used headphones. Now I cannot get sound without them.

    I have a Macbook Pro that I bought in 2008. A few months ago I installed OS 10.9.1. A couple of days ago I used headphones for the first time ever. Now I cannot get sound without them. Help?

    Hi, lolabev.
    You may find the troubleshooting steps in the article below helpful.
    Troubleshooting issues with no audio from built-in speakers on Macs
    http://support.apple.com/kb/ts1574
    Cheers,
    Jason H. 

  • My brand new iphone 6 when charging for the first time gets a message "iphone needs to cool down before using" cannot even charge it

    My brand new iphone 6 when charging for the first time gets a message "iphone needs to cool down before using" cannot even charge it. Have offed and on several times, but same result. Any help on this.

    To resume use of your device as quickly as possible, turn it off, move it to a cooler environment, and allow it to cool down.
    You can read more on :Keeping iPhone, iPad, and iPod touch within acceptable operating temperatures

  • My second brand new iphone 6 when charging for the first time gets the message "iphone needs to cool down before using" cannot even charge

    My brand new iphone 6 when charging for the first time gets a message "iphone needs to cool down before using". I cannot even charge it. I offed it and on it several times, still the same message keeps on coming.

    To resume use of your device as quickly as possible, turn it off, move it to a cooler environment, and allow it to cool down.
    You can read more on :Keeping iPhone, iPad, and iPod touch within acceptable operating temperatures

  • I'm setting up my Time Capsule for the first time and cannot get an internet connection throughWAN connection

    I'm setting up my Time Capsule for the first time and can't get an internet connection via ethernet cord

    So new AC model TC??
    What modem is it? Pure cable modem .. did you power cycle the modem ( OFF for at least 30min..)??
    This is essential to lose the old setup and start afresh. 
    How have you setup the TC?
    Did you try just bridge to existing router? If it doesn't get an IP and you just bought it, possible it is faulty.
    Lots more details.. really important things like did the ethernet connectivity leds go on.. both the TC port and the modem port - front ethernet indicator should light up..

  • When creating a custom default user profile for an image, I get the error "A keychain cannot be found to store "safari" when a new user logs in for the first time.

    My "profile" account works flawlessly with the exception of safari. I had copied the entire user template folder to the default location in OS X 10.10 and removed the entire keychain folder. However, whenever someone logs into the computer for the first time and opens Safari, they are greeted with the error message "A keychain cannot be found to store safari".

    If you've just changed your login password in Recovery mode, follow these instructions. Otherwise, see below.
    At some point, you may have reset your keychain to default in Keychain Access. That action would have caused your login keychain to be renamed.
    Back up all data before proceeding.
    In Keychain Access, delete the login keychain from the keychain list. Choose Delete References when prompted, not Delete References & Files.
    Triple-click anywhere in the line below on this page to select it, then copy the text to the Clipboard by pressing the key combination command-C:
    ~/Library/Keychains
    In the Finder, select
              Go ▹ Go to Folder...
    from the menu bar, paste into the box that opens (command-V), and press return. A folder will open. Rename the file "login.keychain" in that folder to something like "login-old.keychain". Rename the file "login_renamed_1.keychain" to "login.keychain". You can then close the folder.
    Back in Keychain Access, select 
              File ▹ Add Keychain...
    from the menu bar. Add back the file now named "login.keychain". If any of your needed keychain items are missing from it, also add back the file you named "login-old.keychain". I suggest you transfer any needed items from that keychain to the login keychain, then delete it. The transfers are made by drag-and-drop in Keychain Access. You'll need to enter your password for each item transferred.

  • Anyone still up? I just purchased from the itunes store for the first time, and don't know how to get them downloaded to my ipod.

    Sigh.....really late and I want to go to sleep, but I just purchased some Itunes online for the first time, and I don't know how to download them to my ipod. I've never done it before, and it shouldn't be rocket science, but I can't find anything that tells me where to go to download my songs. It said something about check purchases, but I can't even find that screen.  I connected my ipod to the computer, and now it says CONNECTED...EJECT BEFORE DISCONNECTING. My BF set up the acct when he bought my ipod as a gift, and as I bought these songs for a special weekend I have planned I can't ask him how to do it.  HELP!  For some reason the password I always use is not recognized for my account... and since I can't get anyone from itunes without a proper log-in I'm at the mercy of all of you more versed in tech and itunes than I.  Is anyone still up that can help me out?

    It should keep asking for the password, because it's trying to check for purchases... As soon as you login, it will see you have pending downloads and create the downloads section on the left below Purchases under the Store section. Then it will start the music downloads there, as they will be listed one below the other.
    You could just try to check your account balance or view your account and that will trigger a password request too. You can just click on that and say that now iTunes keeps asking for the password and ask him to help you with that. Trick would be to interrupt him so that he carries on with another task after, so he doesn't notice the download. Or you carry on with email or browsing which you were "busy" with when iTunes interrupted you for the password (stupid iTunes)

  • I once created an account and changed meanwhile my Apple ID. Now, when trying to log in to iCloud, I get the message: "You are already logged in". I cannot get access to the account in the way, that, for example, the options appear on the right hand side.

    I once created an account and changed meanwhile my Apple ID. Now, when trying to log in to iCloud, I get the message: "You are already logged in". I cannot get access to the account in the way, that, for example, the options appear on the right hand side.
    What can I do?

    Thank you, pvonk, but:
    To be more precise: I am talking about the logging-in within the System Preferences on my iMac.
    When trying to log in with the old ID, I get no access, i.e. it says "Try again"...-Trying the same with the new one gives me the result I mentioned in my first question...
    Now I found out how to do it: I had to erase all accounts-then I could sign in with my Apple-ID. Thanks again.

  • I've lost a load of notes, but dont know why or how to get them back. I cant find the folder that is in my Yahoo account that people have suggested might be the location for the messages.  I recently signed into iCloud for the first time.

    I've lost a load of notes, but dont know why or how to get them back. I cant find the folder that is in my Yahoo account that people have suggested might be the location for the messages.  I recently signed into iCloud for the first time.  Any idea how to get the notes back?   I really dont want to lose them.

    It should keep asking for the password, because it's trying to check for purchases... As soon as you login, it will see you have pending downloads and create the downloads section on the left below Purchases under the Store section. Then it will start the music downloads there, as they will be listed one below the other.
    You could just try to check your account balance or view your account and that will trigger a password request too. You can just click on that and say that now iTunes keeps asking for the password and ask him to help you with that. Trick would be to interrupt him so that he carries on with another task after, so he doesn't notice the download. Or you carry on with email or browsing which you were "busy" with when iTunes interrupted you for the password (stupid iTunes)

Maybe you are looking for

  • Installation Problem in APEX ver 4.2.3

    Dear Friends, I Installed apex version 4.1 on oracle10g XE. It was working perfectly. When i tried to install apex ver 4.2.3 and ran below commands. @apexins SYSAUX SYSAUX TEMP /i/ @apxchpwd above command worked ok. but when i ran below command @apxl

  • Problem with text direction in table component for text with two language!

    Hi, I want to display text in table component by binding to the one property,and also the language of this text is farsi that must be in the RTL direction. so i defined a direction in style of staticText component in the table. when the text is only

  • Problem saving gif file over the net

    I am using a simple loop to save files using a URL Connection. It grabs html files fine and they look right but when I used to to download an animated gif it had an error. It saved the file but when I tried to open the image I got a "drawing failed"

  • :system.last_record in Oracle Apps Forms

    Hi all, My requirement is when I give order number in header level in Oracle Apps Form, i want the lines to be displayed in lines block. I have written the query and a cursor. The Query returns 6 lines when passing the Order Number. But when i use th

  • Solaris 10 Boot Hangs on T1

    Solaris 10 is hanging during boot from the OpenBoot firmware on my T1. Below is the output from doing an interactive boot from OpenBoot using the "boot -a" command. I use the default values for all options and the boot hangs after the root device is