facebook

Forwaring more than 1 time in servlet

  1. MyEclipse IDE
  2.  > 
  3. Off Topic
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #222840 Reply

    wk3000sg
    Member

    Is there any way to forward more than 1 time in the servlet?
    Eg. while(..){
    …..
    }
    As long as the statement is not false, it will keep forwarding eg like
    “request.getRequestDispatcher(“/WEB-INF/pages/view.jsp”).forward(request, response); ”

    Any help would be appreciated. ty.

    #222875 Reply

    Riyad Kalla
    Member

    A forward represents a committed response, meaning the server has ‘replied’ to the client, and the client has closed the connection. You cannot keep replying to the client because you will (a) get exceptions and (b) even if you didn’t, the client wouldn’t be listening to your traffic and wouldn’t do anything with the responses you sent.

    #222910 Reply

    wk3000sg
    Member

    Because I am trying to do a multiple sql statements in a textarea. And i am using Stringtokenizer to split those lines. Stringtokenizer token=new Stringtokenizer(sql, “;”);
    eg. select * from table;
    delete from table where a=1;

    As a result, i encounter problem that it cannot forward more than 1 sql statement more than once. therefore, the servlet only run the first sql line. Is there any idea how to do it?

    #222912 Reply

    Riyad Kalla
    Member

    If I understand your program correctly, you allow people to type SQL into a text box, then you parse each line, run the query, and return it to the user? If this is the case, then you either need to limit the SQL to one comment, or run all of the statements before replying to the client.

    #223381 Reply

    Robert Varga
    Participant

    I guess, what you really want is an include, not a forward….

    After a forward, you MUST return immediately (after cleaning up the resources, but not calling anything on response (except for flush, possibly)).

Viewing 5 posts - 1 through 5 (of 5 total)
Reply To: Forwaring more than 1 time in servlet

You must be logged in to post in the forum log in