How to do redirect in servlet???

hi...
i want to know .....i have a servlet where its jobs is to get an input and send it to an application and that application gives the output.however after the application gives the output.....the servlet will generated a blank html pages. i want it to redirect to other pages like thank you page etc. how to do this???

u can use...
response.sendRedirect("url") if u want a client-side redirect..
or use requestDispatche which accepts request and response objects as arguments if u want a server side redirect..

Similar Messages

  • Urgent....How can i redirect to my jsp page from servlet in init() method..

    How can i redirect to my jsp page from servlet in init() method..Becoz that servlet is calling while server startsup..so im writing some piece of code in init() method..after that i want to redirect to some jsp page ...is it possible?
    using RequestDispatcher..its not possible..becoz
    RequestDispatcher rd = sc.getRequestDispatcher("goto.jsp");
    rd.foward(req,res);
    Here the request and response are null objects..
    So mi question can frame as how can i get request/response in servlet's init method()..

    Hi guys
    did any one get a solution for this issue. calling a jsp in the startup of the servlet, i mean in the startup servlet. I do have a same req like i need to call a JSP which does some data reterival and calculations and i am putting the results in the cache. so in the jsp there in no output of HTML. when i use the URLConnection i am getting a error as below.
    java.net.SocketException: Unexpected end of file from server
    at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:707)
    at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:612)
    at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:705)
    at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:612)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLCon
    nection.java:519)
    at com.toysrus.fns.alphablox.Startup.callJSP(Unknown Source)
    at com.toysrus.fns.alphablox.Startup.init(Unknown Source)
    at org.apache.tomcat.core.ServletWrapper.doInit(ServletWrapper.java:317)
    so plz do let me know how to call a jsp in the start up of a servlet.
    Thanks
    Vidya

  • How can i redirect to another JSP page automatically after some event

    I am developing a Tic-Tac-Toe game which can be played between two players who are on two different machines.
    When the first player comes to the Welcome page he will redirected to a Waiting Page when he clicks on the 'Start' button.
    When the second player comes to the Welcome page he will be redirected directly to the Game page, on clicking the 'Start' button.
    So how can i redirect the first player to the Game page after the second player is available for the game.
    And if i want to manage multiple instances of my game how can i do that//
    I am using JSP, javascript and MySQL for developing my project, and I am new to all these tools, but i would still like to carry on with all these only

    This is a bit of a challenge because of the nature of the web. Generally the web is "pull only" meaning that the browser has to initiate any interactions - the server can't push data to the browser if it wasn't asked to.
    The easiest way to solve this is using AJAX via JavaScript to periodically poll the server for any status changes. There are other ways (the Comet protocol is one) but they start to get a bit difficult and are still a bit new and not completely supported in a standards way. And to be honest they are still basically polling though in a more efficient way.
    Are you using a JavaScript framework? Most of the JavaScript frameworks that I've used have built in support for polling in the background. You'd have to have the JSP/servlet side be able to handle these polling requests from the browser and, when another person joins the game, the server indicates that and sends that back to the browser.
    As far as multiple instances I would have the server automatically pair up users as needed. So when the first player arrives he has to wait for another player. When the second player arrives a new game is created for those two players. Now a third player arrives and waits until a fourth player shows up. When player 4 joins another separate game is created. Presumably the conversation between the browser and the server will need to include a "game number" or other unique number so that the server can keep track of the games.

  • How to call two different servlet-url in the same application

    Hi,
    I want to call, consecutively these methods in my application.
    response.sendRedirect(servlet-url1)
    reponse.sendRedirect(servlet-url2)
    but the second method dont answer,
    I think, the first method redirect s with response ,
    but how to call two different servlet ?
    thanks

    if you call the first redirect, the servlet is getting aborted, so you can redirect to the first servlet, working the stuff in it, and then in the second servlet you can redirect to the third servlet

  • Redirecting the servlet output to jsp

    Hi i need to redirect my servlet out put to jsp
    in result set's every row i have 9 columns
    this result set how can i redirct to jsp
    plz can any one let me know with an example
    thanks a lot in advance

    inamdar wrote:
    Hi i have never used DTO's and DAO classes
    plz colud u let me know without using that..Huh? It is never too late to start with it. Just create two simple classes. A DTO class is basically a simple javabean with private (encapsulated) properties and a public getter and setter for each property. A DAO class is basically a class which contains purely JDBC code.
    Sample DTO:public class MyData {
        private Long id;
        private String name;
        private Integer value;
        public Long getId() { return id; }
        public String getName() { return name; }
        public Integer getValue() { return value; }
        public void setId(Long id) { this.id = id; }
        public void setName(String name) { this.name = name; }
        public void setValue(Integer value) { this.value = value; }
    }Sample DAO:public class MyDataDAO {
        public List<MyData> listAll() {
            String listAllQuery = "SELECT id, name, value FROM data";
            List<MyData> myDataList = new ArrayList<MyData>();
            Connection connection = null;
            Statement statement = null;
            ResultSet resultSet = null;
            try {
                connection = getConnectionSomehow(); // DriverManager or Connection Pool, your choice.
                statement = connection.createStatement();
                resultSet = statement.executeQuery(listAllQuery);
                while(resultSet.next()) {
                    MyData myData = new MyData();
                    myData.setId(new Long(resultSet.getLong("id")));
                    myData.setName(resultSet.getString("name"));
                    myData.setValue(new Integer(resultSet.getInt("value")));
                    myDataList.add(myData);
            } catch (SQLException e) {
                // Handle it. Print it, throw it, log it, mail it, your choice.
                e.printStackTrace();
            } finally {
                // You can write an utility class/method for those lines as well.
                if (resultSet != null) { try { resultSet.close(); } catch (SQLException e) { e.printStackTrace(); } }
                if (statement != null) { try { statement.close(); } catch (SQLException e) { e.printStackTrace(); } }
                if (connection != null) { try { connection.close(); } catch (SQLException e) { e.printStackTrace(); } }
            return myDataList;
    }Sample Servlet code:List<MyData> myDataList = new MyDataDAO().listAll();
    request.setAttribute("myDataList", myDataList);
    request.getRequestDispatcher("someJspFile.jsp").forward(request, response);Sample JSTL code in someJspFile.jsp:<table>
        <c:forEach items="${myDataList}" var="myData">
            <tr>
                <td>${myData.id}</td>
                <td>${myData.name}</td>
                <td>${myData.value}</td>
            </tr>
        </c:forEach>
    </table>Simple and clean, isn't it?

  • How do I redirect  the "Documents" folder to a different partition?

    I have a separate data partition on my 10.5.1 MacBook and I want all my user data to live there. How do I redirect the "Documents", "Desktop" and "Downloads" folders to a different partition?

    As far as I know the desktop can't be assigned elsewhere. The others can be directed with the respective programs. I always keep my documents on another drive. I do it by using the saves as command and point to that directory. Then everything after that I can use there. For Downloads you just change it in preferences in Safari. Switch it in the *Save downloaded files to:* command.

  • How can I redirect LR to find my photos, which I just moved.

    Long story, but when I set up my new computer (Win 7/64) I found myself with two My Pictures folders, one nested inside the other, on my data drive.  The photos were in the second or inner folder.  No big deal except having to click twice to get the images files.  Well, then I loaded LR 5.2 which set up its Catalog inside the outer folder, and really really wanted to load downloaded photos there as well.  No problem, I though, I'll just opent the inner My Pictures folder, cut the files, then paste them in the outer folder along with the LR catalog.  A benefit is I can backup the Catalog at the same time as the photos.  Welllll, not.  LR can no longer find the photo locations, althoug it can still find its catalog.  How do I redirect LR to the right location for all the photo files, including of course, those that I've already imported.  Is there anything I need to do with the catalog as well?
    Thanks much,
    BAB

    B4A5B6 wrote:
    Thank you, dy_paige !!  Using the information you sent I was able to fix the problem with one operation:  right-clicking on the old directory for My Pictures and repointing to the new.  The tutuorial you sent was absolutely correct in that additional instruction is needed to perform this task safely.  I found the the command "Find New Folder" easily enough, but was hesistant to go any further.  It is far too easy to seriously mess up a
    But you've already messed up the catalog.
    The much simpler approach is to not move photos at all, then you never have this problem. It's simple and effective.

  • How can I run a servlet with Sun Java System Application Server PE 8?

    I've created a package with a TestServlet.class inside, used the deploytool to create a WAR and deployed this using the autodeploy folder.
    The filestructure has been generated and I find the TestServlet.class in
    [installdir]\domains\domain1\applications\j2ee-modules\testProject\WEB-INF\classes\[packagefolderstructure]\TestServlet.class.
    The context root is working fine, but I have no clue how I can run the servlet directly via the URL.
    I've tried many things like
    http://localhost:8080/testProject/TestServlet
    http://localhost:8080/testProject/servlet/TestServlet
    http://localhost:8080/testProject/servlet/[packagenamewithpoints]TestServlet
    http://localhost:8080/testProject/servlet/[packagenamewithslashes]TestServlet
    etc etc
    Can somebody tell me please how to write URLs to deployed servlets? Or send me an example url and xml descriptor files?
    Thanks a lot in advance!

    in web.xml use servlet mapping
    <servlet-mapping>
        <servlet-name>TestServlet</servlet-name>
        <url-pattern>/doit</url-pattern>
    </servlet-mapping>then use http://localhost:8080/testProject/doit

  • How can i redirect a queued call to a voicemail using CCX editor?

    hi buddies, i wonder how can i redirect a queued call to a voicemail of a valid extension using CCX editor?
    i just uploaded my script (does not working as i wanted regarding voicemail)if can anybody help me i will be very happy!!

    first of all i REALLY A REALLY appreciate your reply
    but two questions remain:
    a) check my attached file is this the VM pilot number?
    b) Called Address = "2133"  means that the call will be redirected to the voicemail of the 2133 extension? im right??

  • How do we run a servlet program in eclipse

    how do we run a servlet program in eclipse.

    Not at all, because servlets require a servlet container. Some Eclipse plugins (Lomboz etc.) do provide integration with those.

  • How do I redirect formula links in a duplicated table?

    I am putting together an annual accounts spreadsheet in Numbers. I have several worksheets with a set of tables for the first month. The final worksheet contains a summary table which gathers data from across all the tables on the other sheets. No problem so far. But when I create a new set of tables for the second month I also duplicate the summary table. Now all the values are still drawn from the first month tables. How can  I redirect all the formulas to the second set of tables? Is this possible?
    If this sounds a bit confusing, this is what I am trying to do by way of simple demonstration;
    I create Table A (January) in Worksheet 1
    I create Table B (January Summary) in Worksheet 2 - this contains formulas drawing information from Table A
    I duplicate Table A in worksheet 1 to make Table C (February) - and overwrite the cells with new data values. Table C remains in worksheet 1
    I duplicate Table B in Worksheet 2 to make Table D (February Summary). Table D remains in Worksheet 2. However, all the data values are still drawn from Table A (January). I now want them all to point to Tabel C (February) without having to manually re set all the formulas.
    There doesn't appear to be a one command way of doing this. Nor can I double click the cell formulas and type in a simple change - it seems I have to start the formula set up all over again.  Any help would be appreciated - even if it is bad news! I'm quite new to Numbers - but finding my way around!
    Many thanks

    Hi John,
    Rather than struggling with so many separate tables and formulas, which sounds unwieldy and error-prone, have you considered entering your data in one table and extracting monthy summary statistics and views as needed?  For example you could have something like this:
    The Purchases Data table contains only data you enter. There are no formulas there.
    There is only one formula in the Summary table, here copied from B2 across and down:
        =SUMIFS(Purchases Data::$D,Purchases Data::$B,$A2,Purchases Data::$C,B$1)
    Granted, it's an indimidating-looking formula. But if you look up SUMIFS in the function browser you'll see how it works. It's much easier than it looks.  The first argument within the () is the column you want to sum. The other arguments are column-condition pairs, where each condition applies to the column just before it.
    So the formula here in B2 is saying, add up all the numbers in column D of the Purchases Data table (the first argument) where the value in column B of the the Purchased Data table is the same as the value in A2 of the Summary table (the first column-condition pair) and the value in column C of the Purchases Data table is the same as the value in B1 of the summary table (a second column-condition pair). You can add more column-condition pairs as needed.
    Using this approach you can also quickly extract monthly summary tables.  In this simple example, you set one up and get it working for the first month, then copy/paste the whole table, change its name and the month number in A1 and you're done. No need to further fuss with formulas:
    Formula in B2, copied to C2:  
          =COUNTIFS(Purchases Data::$B,$A$1,Purchases Data::$C,B$1)
    Formula in B3, copied to C3:  
          =SUMIFS(Purchases Data::$D,Purchases Data::$B,$A$1,Purchases Data::$C,B$1)
    Then, say, you want to list all the Cafe purchases in January, you simply apply a filter to the Purchase Data table like this:
    SG
    P.S. Sharing via iCloud here is easy:
    Copy the link, click the in the editor and paste it in.

  • How do I redirect my IPhoto Folder from 1st hard drive to 2nd hard drive on my Mac Pro ?

    How do I redirect my IPhoto folder on my first hard drive (500 GB) to the the second hard drive (1TB) in my Mac Pro.  I don't want a copy, but to move it away from the smaller HD, as it is almost at max!!
    I started with drag and drop from one HD to next HD, but it looked as if it was just going to be a copy. 
    Thank You

    iPhoto: How to move the Library folder to a new location
    Delete the original after copying it.

  • How can I test a Servlet?

    Hello!
    I want to test a small part of a servlet. That part connects to a database through a DataSource which is obtained in this manner:
    Context ctx = new InitialContext();
    ds = (DataSource) ctx.lookup(dsLookup);
    conn = ds.getConnection();Details about the servlet: runs on a WebSphere application server with db2 database. Runs on the local server in our intranet and I create a Java project in Eclipse with Create project from existing source: path to location on server.
    It's really annoying to start the browser, get to the page I'm interested, make the neccesary request and then see what happens in my code.
    What I've learned so far:
    I can't test it in a main function because I can't get the context. I tried setting the context's properties, still no go.
    I found this: http://www.ibm.com/developerworks/rational/library/08/0219_jadhav/
    but I got lost when it came to adding the resource reference to the project. How can one do that in Eclipse?
    Can anyone please, please, pretty please with sugar on top, explain to me how I can do this?
    Thank you very much for your time,
    Iulia

    Thank you for your prompt reply. I still have some questions:
    You say that configuration must go in the web.xml file. I don't have that file. In the tutorial example one application is a Java project the other is an application client and the other is an EAR of the application client. Neither of them have a web.xml file. So where do I set the resource?
    Do I have to have a WebSphere application server installed on my local machine?Where and how do I run the servlet?
    Thank you,
    Iulia

  • How do i redirect wifi sync in iOs 5 to a different computer user

    how do i redcirect wifi sync to a different user on the same computer? how do I redirect wifi sync to a different computer on the same network?

    Jeffrey Briggette wrote:
    Is this possible?
    Jeff ~ Yes. Make a copy of the iWeb Domain file (normally located in the ~/Library/Application Support/iWeb folder, although it can be moved) and then open it in iWeb by double-clicking. Delete the site you don't want in that Domain file by selecting the site in the left side column and then Edit menu > Delete Site. Then you can transfer than Domain file to another computer, but check out NOTE 1 here:
    http://iwebfaq.org/site/iWebTwocomputers.html
    And see these Apple docs:
    iWeb 2.0 Help (iLife '08) — Modifying your site from another computer
    iWeb: Publish to your MobileMe account from more than one computer
    And this tutorial may also be useful:
    http://web.me.com/toad.hall/OldToadsTutorials/No._21.html

  • How to inject ejb in servlet

    hi all
    How to inject ejb in servlet ?
    please explain how to config my servlet and my paroject
    I have an ear file with two jar files
    Thanks in advance

    hi
    I have this error in my project
    I have an ear file ,two war file and three jar file in it
    and I did configuration
    but there was this error
    14:19:45,398 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[conference-servlet].[enterLet]] Allocate exception for servlet enterLet: javax.naming.NameNotFoundException: ITrmnlAuthenticationBL not bound
    @Remote
    public interface ITrmnlAuthenticationBL{
    @Stateless
    public class TrmnlAuthenticationBL implements ITrmnlAuthenticationBL{
    public class EnterLet extends HttpServlet {
         @EJB(mappedName = "ITrmnlAuthenticationBL")
         private ITrmnlAuthenticationBL trmnlMg;
    please explain my mistake

Maybe you are looking for

  • What will be input for custom module developed for JDBC adapter

    Hi, I have a scenario SQLDB -> Xi -> R3 . Here I have added a custom module before callsapadapter module. As I know the sequence of module calling will be as follows : 1. Standard jdbc adapter 2. custom module 3. callsapadapter Standard jdbc adapter

  • Pls tell me checkings to be made in pr workflow

    dear friends, kindly tell me what are all the things to be checked in pr with workflow. please provide me a valauble solution. thanks in advance. i am unable to release the pr in second level(by the user). thanks in advance regards, flemmings

  • Where Can I find Linux for Oracle?

    Please tell me where I can find it. Pao. @}-->>-----

  • Exporting file to jpg

    Can anyone help please. I have been trying to export my swf to a jpg. The picture is going to be used for the background to my site. The dimensions of the image are 1000px by 1 px. I get a message that I can not export with anything less than 4px wid

  • ABAP Webdynpros Development standards

    Hi ALL Does any body has any Documents regarding development standards for ABAP Webdynpors.. Thanks in advance any help will be much rewarded. cheers AJ