<jsp:include>

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • lalia
    New Member
    • Sep 2009
    • 2

    <jsp:include>

    I have a xyz.jsp page has a submit button
    This page is included in another jsp file by <jsp:include page="/../xyz.jsp"/> tag.
    when i click that button the whole main page get submit where i only want to submit only the xyz.jsp page only.So how to achieve this thing?
  • sumittyagi
    Recognized Expert New Member
    • Mar 2007
    • 202

    #2
    You can achieve this by using ajax.

    Comment

    • lalia
      New Member
      • Sep 2009
      • 2

      #3
      Hi Sumit Tyagi
      I have heard that using ajax this problem can be solved.But i don't want to use ajax.So how can it be possible?Have you any idea?


      Thanks

      Comment

      • r035198x
        MVP
        • Sep 2006
        • 13225

        #4
        Originally posted by lalia
        ...But i don't want to use ajax...
        Why?


        Originally posted by lalia
        ..So how can it be possible?Have you any idea?
        Use Ajax.

        Comment

        • sumittyagi
          Recognized Expert New Member
          • Mar 2007
          • 202

          #5
          You must understand two things for developing web applications:-
          1. Client side programming (scripting).
          2. Server side programming.

          When client submits the request then(and only then) server gets the control.
          Now you want to control how client submits the request, so that needs client side scripting (server can't help you in this as he is sitting miles away from your computer).

          Now what is AJAX!
          AJAX is an architecture, that combines client side technologies and teaches you to control client side programming in a well organized manner.

          There are many frameworks that do the ajax part for you, and you don't need to worry much about AJAX in that. (But even in that case you must have an understanding of AJAX).

          If you have more queries about AJAX, then go to javascript forum and put your question, and you will get advice from Javascript and AJAX specialists.

          ~Cheers~
          Sumit

          Comment

          • Frinavale
            Recognized Expert Expert
            • Oct 2006
            • 9749

            #6
            While Ajax is a great suggestion, I can understand why you would want to avoid Ajax at this time. I don't think that the experts here know how much time it takes to learn a whole new concept/language...I mean, they already know how to use it so it seems quite simple to them. You should take the time to learn Ajax though, it's very cool stuff that is easy to use once you understand it... but to understand it you have to have a firm understanding of JavaScript and client-server interactions which takes a while to learn.

            So instead I'm going to recommend that you try using an iframe.

            In this recommendation you don't actually use the <jsp:include> to include the xyz.jsp page into your page.

            An iframe lets you show more than one page on the same page.

            The iframe is another "window" within the page so make sure that you understand how these work before attempting to use it....

            It will let you have the xyz.jsp page on the same page as your main.jsp page, however anything within the iframe will only submit to the xyz.jsp page.

            Your main page would look something like:
            Code:
            <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
            <html xmlns="http://www.w3.org/1999/xhtml">
            <head id="Head1" runat="server">
                <title>Some page</title>    
            </head>
            <body>
              <form id="mainForm"action="MainPage.jsp" method="post" name="mainForm">
                <!-- .... Main Page Content ...  -->
                 <iframe id="xyziframe src="xyz.jsp"></iframe>
                <!-- ... More Main Page Content ... -->
              </form>
            </body>

            Or, you could have 2 <form>s on the same page but you have to be careful that they are not inside one another.

            Using my second idea involves your main page looking like:
            Code:
            <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
            <html xmlns="http://www.w3.org/1999/xhtml">
            <head id="Head1" runat="server">
                <title>Some page</title>    
            </head>
            <body>
              <form id="mainForm"action="MainPage.jsp" method="post" name="mainForm">
                <!-- .... Main Page Content ...  -->
              </form>
              <form id="xyzForm"action="xyz.jsp" method="post" name="xyzForm">
                <!-- .... XYZ Page Content ... -->
              </form>
            </body>

            This would mean that your xyz.jsp page would only print out <form>...conten t...</form> and wouldn't be a full page (by full page I mean includes the <html></html> tag)

            Hope this helps

            -Frinny

            Comment

            Working...