Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Java > Java and JDK > JSP Basics
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
JSP Basics Beginning-level questions on JSP. More advanced coders should post to Pro JSP.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the JSP Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old May 27th, 2008, 03:05 AM
Registered User
 
Join Date: Sep 2007
Location: navsari, gujarat, India.
Posts: 6
Thanks: 0
Thanked 1 Time in 1 Post
Default master page in JSP

hi all,

i m new to JSP n want to include master page feature in my project.

plz help me in doing so.

regards

tanzi
Reply With Quote
The Following User Says Thank You to tanzi For This Useful Post:
  #2 (permalink)  
Old May 29th, 2008, 08:47 PM
Registered User
 
Join Date: Oct 2007
Location: , , .
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

First - what have you done to help yourself?

Reply With Quote
  #3 (permalink)  
Old June 5th, 2008, 06:40 AM
jomet
Guest
 
Posts: n/a
Default


in my knowledge master page feature is in asp.net

use css templates instead


jomet.
`````````````````````````````````````````````````` ``````````````````````
Once you start a working on something, dont be afraid of failure and dont abandon it.
People who work sincerely are the happiest.
Reply With Quote
  #4 (permalink)  
Old November 2nd, 2008, 07:22 PM
Registered User
 
Join Date: Nov 2008
Location: , , .
Posts: 1
Thanks: 0
Thanked 2 Times in 1 Post
Default

I got interested for the problem so I found out something for you.

First we have to create an embedded page, we can name it for example "TestForm".

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
  <head/>
  <body>
      <%
           if (request.getParameter("fromMasterPage") == null)
           {
                %>
                  <jsp:forward page="masterpage.jsp">
                    <jsp:param name="embeddedPageName" value
                     ="testform.jsp"/>
                     <jsp:param name="submitPageName" value
                     ="processdata.jsp"/>
                  </jsp:forward>
                <%
           }
      %>
      <input type="submit" value="go to processdata.jsp"
      name="submit"/>
  </body>
</html>

If the page even has not been included in the masterpage, we have to
forward to a masterpage witch will contain it (the forward will not change the context parameters e.g: request parameters or attributes, current path etc.)
After that we can dinamically include any other
page into the masterpage and we can also dinamically set the form's action parameter. See this in the first snippet in jsp:forward.

This is the master page:

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
  <head><title>Simple jsp page</title></head>
  <body>
      <%
        String embeddedPageName =
        request.getParameter("embeddedPageName");
        String submitPageName =
        request.getParameter("submitPageName");
      %>
      <form action="<%= submitPageName %>" method="POST">
      -- Header --
         <br/>
         <jsp:include page="<%=embeddedPageName%>">
         <jsp:param name="fromMasterPage" value="true"/>
         </jsp:include>
         <br/>
      -- Footer --
      </form>
  </body>

"jsp:include" also preserves all request info.
"fromMasterPage" will be set to "true" to prevent another forward to masterpage. This is something like that asp does.
I think you could wrap the part between header and footer
into an ajax panel (AjaxTags). I hope it will work well in every cases.


Reply With Quote
The Following 2 Users Say Thank You to foulton For This Useful Post:
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Master Page Method: Code-Behind for Content Page kwilliams ASP.NET 2.0 Professional 3 June 2nd, 2008 12:57 PM
Master Page and Content Page with Java script Harjinder ASP.NET 2.0 Professional 1 February 1st, 2008 10:31 AM
master page and content page interaction mrjoka ASP.NET 2.0 Basics 0 March 15th, 2007 10:45 AM
Access Master page control from Content page. angshujit ASP.NET 2.0 Basics 3 January 11th, 2007 06:20 AM
Bookmark this page link in Master page dschips ASP.NET 2.0 Basics 5 January 8th, 2007 11:05 AM



All times are GMT -4. The time now is 03:21 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.