Results 1 to 6 of 6
  1. #1
    Join Date
    Apr 2008
    Posts
    64
    Rep Power
    0

    Default <jsp:include> Vs <%@include> Vs <jsp:forward> Vs RequestDispatcher .forward/includeVs

    Hi there,
    can anyone give a clear answer for my below question.........

    what is the difference between the bwlow,

    <jsp:include> Vs <%@include> Vs <jsp:forward> Vs RequestDispatcher .forward/includeVs response.sendRedirect()..........

    any answers really appricated........

    Regards

  2. #2
    sanjeevtarar's Avatar
    sanjeevtarar is offline Senior Member
    Join Date
    Apr 2008
    Location
    Jaipur(India)
    Posts
    318
    Rep Power
    7

    Default

    Hello Dear..

    <jsp:include> : to include pages at request time , JSP content cannot affect main page: only output of included JSP page is used
    <%@include> : (the include directive) to include files at page translation time, To reuse JSP content in multiple pages, where JSP content affects main page


    RequestDispatcher .forward/include : Is used when we want to forward request from server to server there is no client interaction.

    response.sendRedirect() : In this case client is involved, first request is forwarded to client and then new request is generated from client side. In this case Header value is set by server to tell the client browser to generate new request.

    When you invoke a forward request, the request is sent to another resource on the server, without the client being informed that a different resource is going to process the request. This process occurs completly with in the web container. When a sendRedirtect method is invoked, it causes the web container to return to the browser indicating that a new URL should be requested. Because the browser issues a completly new request any object that are stored as request attributes before the redirect occurs will be lost. This extra round trip a redirect is slower than forwa
    It is good to user RequestDispatcher then sendRedirect.



    sanjeev


  3. #3
    Join Date
    Apr 2008
    Posts
    64
    Rep Power
    0

    Default

    yeah thanks sanjeev...
    i always use only and <jsp:include> sendRedirect... May be from now i ll use the other..... However am confused wen to use what.... N'way thanks for relplying man.....
    regards

  4. #4
    javarishi is offline Member
    Join Date
    Apr 2008
    Posts
    91
    Rep Power
    0

    Default

    Hei,
    <%@include> The Include Directive includes The contents( jsp

    pages ) statically. You Can Pass Some Data With This Mechanism,

    Since The Code Is Appended In The Including Page.

    <jsp:include> The Include Action includes The Response Or OutPut Of

    The Page Dynamically.

    So The Pages Which Changes frequently, Include With The Include

    Action <jsp:include>

    And

    Pages Which Change Infrequently, Use The Include Directive.

  5. #5
    vijaysdange is offline Member
    Join Date
    Jul 2008
    Posts
    2
    Rep Power
    0

    Default Hi

    As per my knowledge

    <jsp:include page="/index.html" /> allow all kind of html and images and text files in pages

    where as

    <%@include allows only jsp pages.

    correct me if i am wrong..................i have confusion on this.

  6. #6
    DevzAbhi's Avatar
    DevzAbhi is offline Member
    Join Date
    Jul 2008
    Posts
    67
    Rep Power
    0

    Default

    RequestDispatcher .forward can be used when you are in same server context taht is within the same app server .

    if in any exception you need to send the parameter to some other server or Domain you need to use response.sendRedirect()

    i hope this helps

Similar Threads

  1. Include file from other proyect
    By oleg_gunnar in forum Advanced Java
    Replies: 1
    Last Post: 03-08-2008, 07:20 PM
  2. Include Java file in HTML Page
    By kathyc in forum New To Java
    Replies: 2
    Last Post: 03-07-2008, 04:51 AM
  3. jsp:forward action
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 12-24-2007, 11:04 AM
  4. jsp:include and include file
    By Heather in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 07-14-2007, 05:19 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •