Newbie HELP - JSP includes

Hi,
I want need to create JSP pages which will have (1) Header (2) Body and (3) footer. The header and footer i am clear about including. But the body has to have two parts (a) a fixed sidebar part with hyperlinks and on the rights side (b) body contents.
For body, i am thinking of creating a table with two colums and use dynamic include jsps in each column respectively.
Will it work?. Is there any better way?
Appreciate the help...

Will it work?. Sounds good to me.
Is there any better way?You might want to take a look at the Struts:Tiles framework.
It is a set of tags which help you do exactly this sort of thing.
It lets you define templates, and then just define what is different on each page (ie the body content)
You don't have to be using Struts to use Tiles. It is standalone.

Similar Messages

  • Jsp:include not working - Please Help.

    I am trying to do a jsp:include page but I must have the syntax wrong for the declaration of the filename. There shouldn't be a problem with my included file since it only has the word "TEST" in it. Both files are in the same directory. The error I'm getting is a 404 error.
    Message:File not found: null
    Target Servlet: File Serving Enabler
    StackTrace:
    If you look at the code, you'll see that I am doing two includes, one using the directive and one using jsp:include. The directive one comes up fine but not the jsp:include. Thanks for any help. Here's my code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML><HEAD>
    <META name="GENERATOR" content="IBM WebSphere Page Designer V3.5.3 for Windows">
    <META http-equiv="Content-Style-Type" content="text/css">
    <TITLE>This is the page title</TITLE>
    </HEAD><BODY>
    <center>
    <table border="1">
    <tr>
    <td align="center"><jsp:include page="navigationTest2.html" flush="true"/></td>
    <td align="center"><%@ include file="navigationTest2.html" %></td>
    </tr>
    </table>
    </center>
    </BODY></HTML>

    Yeah I know, I tried that. I did notice that the directive include doesn't accept the path the same way. If I put in the full path /test/navigationTest1.html the compile would tell me couldn't read file, but the path of the file it was trying to read was /test/test/navigationTest1.html. I took the /test out and just left the / and could not read the file in the root dir, of course, because it's in the test dir. So now I have the full path /test/navigationTest1.html in the jsp:include and no path in the directive include and same results.

  • Problems with Tomcat 4.0 and jdk 1.3.1 (jsp:include) Help Gurus...

    Im running examples of the include:
    <jsp:include page="xxx.jsp" flush="true">
    and received error:
    org.apache.jasper.JasperException: No se puede compilar la clase para JSP
    An error occurred at line: 17 in the jsp file: /jsp/include/include.jsp
    Generated servlet error:
    /Programas/Tomcat4/work/localhost/examples/jsp/include/include$jsp.java:79: Method include(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, java.lang.String, javax.servlet.jsp.JspWriter, boolean) not found in class org.apache.jasper.runtime.JspRuntimeLibrary.
    JspRuntimeLibrary.include(request, response, "/jsp/include/foo.html" + jspxqStr, out, true);
    ^
    Please Help me Im running this equal with:
    <%@ include file="xxx.jsp" %>
    and runnig fine....

    The two means of including files are different in their approach.
    Using <jsp:include .../> compilation of the included jsp is done at run -time not during compilation.
    Using <%@ include .../> compiles at compile time.
    Looking at the error it seems that the method JspRuntimeLibrary.include is not being found which suggests that you may have a classpath problem. Check that there is not a servlet.jar in the classpath that is from a earlier spec than the one provided with Tomcat.
    Dave

  • Jsp include Help

    Dear Reader,
    Pls help me with this problem
    I have a html file iam including it in my jsp page
    <jsp:include page="foo.html" flush="true"/>
    is there a way i can get the html fields of foo.html
    and set value
    Thnaks in advance...

    Hi,
    You can pass parameters to the included file, just make it foo.jsp instead.
    <jsp:include page="foo.html" flush="true">
    <jsp:param name="foo" value="bar" />
    </jsp:include>

  • Total newbie for jsp..plz help

    frendz...me a total newbie to jsp.havin some problem in it.i have already installed jdk,jwsdp2.0 wif its tomcat container.Already set the path for both ..such as JAVA_HOME=E:\Program Files\Java\jdk1.5.0_06
    TOMCAT_HOME=E:\tomcat50-jwsdp
    and could execute the sample jsp's perfectly.But having problem wif my jsp tutorials. such as when i wrote this counter codes in notepad..
    <%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*" errorPage="" %>
    <html>
    <head>
    <tittle>Jsp Declaration</tittle>
    </head>
    <body>
    <h1>Declarations</h1>
    <%! int j=0;%>
    <h2>Counter</h2>
    <p>This page has been hit <span> <% ++j %> </span> times since it was first loaded.</p>
    </body>
    </html>
    and i paste it in webapps in tomcat folder.
    What should i do to view the jsp file?isaved as counter.jsp.if i right click and view it in IE/firefox it only shows the source code.is there any mistake in the codes?or i did i do anything wrong?how shall i compile these files?help me aout wif my basics please.thanks bro's..

    "I pasted it in webapps in tomcat folder".
    Webapplications need to go in their own subdirectory inside the webapps directory. Say you want a webapp 'test', then you would store your JSP as
    TOMCAT_DIR\webapps\test\counter.jsp
    Now you can open this JSP in your browser. Assuming Tomcat is running on the localhost and the default port 8080, the url would be:
    http://localhost:8080/test/counter.jsp
    If that doesn't work something is horribly misconfigured.

  • [JSP/Newbie]: howto write my own jsp:include tag?

    Hi folks,
    I'm trying to write a replacement tag for <jsp:include> (which shall later decide upon its context what to include..), i.e. I want to include another JSP from within a tag.
    Unfortunately right now my best bet does not allow to control the position of the included JSPs output in my output stream - it prints directly :-((
    // index.jsp is my startpage:
    <%@ taglib uri="/cistags" prefix="cis" %>
    index.jsp START:
    <cis:include file="/theincludefile.jsp" />
    index.jsp ENDE
    // theincludefile.jsp is the included file
    -->INCLUDEFILE<--
    // include.java is my current idea to approach this:
    public class include extends TagSupport {
    private String jspName;
    public void setFile(String name) {
    this.jspName = name;
    public int doEndTag() {
    HttpServletRequest request =
    (HttpServletRequest) pageContext.getRequest() ;
    HttpServletResponse response =
    (HttpServletResponse) pageContext.getResponse() ;
    try {
    request.getRequestDispatcher(
    response.encodeURL(jspName)).include(request,response) ;
    catch (Exception e) { }
    return EVAL_PAGE;
    the result expected is:
    index.jsp START:
    -->INCLUDEFILE<--
    index.jsp ENDE
    but instead I receive:
    -->INCLUDEFILE<--
    index.jsp START:
    index.jsp ENDE
    So how can I get hold of the ouput generated by the JSP I'm calling through RequestDispatcher.include so that I can rewrite it into my own output stream here?
    Is someone out there able to point me into the right direction?
    Ingo
    [email protected]

    check this article out
    http://www.javaworld.com/javaworld/jw-09-2000/jw-0915-jspweb.html

  • HELP: JSP simple examples

    Hi:
    i am a newbie to JSP and am trying to come up with few SIMPLE example JSP pages QUICKLY e.g.
    -using URL variables
    -form submission
    -email
    etc.
    could you give reference to simple code or tutorial which covers it.
    appreciate your help
    -Z

    Did you try downloading Tomcat and running through their examples? They're pretty elementary, show all the examples you mention (including an email example) and show the source code.
    Download/install Tomcat, get it running, and go to http://localhost:8080/examples/jsp/ for the JSP examples.

  • JSCookMenu and jsp:include

    I'm newbie to JSF. I want to add dynamic menu to my page. and when click on a menu Item in the same page I want to display corresponding page. So, I tried to use jsp:include tag to display the page.
    <f:subview id="myMenu">
                <t:jscookMenu layout="hbr" theme="ThemePanel" >
                    <t:navigationMenuItems value="#{dynMenu.navItems}" />
                </t:jscookMenu> 
    </f:subview>     
    <f:subview id="midPage" rendered="#{dynMenu.pageUrl != null}">          
              <jsp:include page="customer.jsp"/>
    </f:subview>but when I use this way Menu is not displaying
    If I remove <jsp:include page="customer.jsp"/> then menu is displaying.
    (in the page If I use jsp:include tag any where, the menu is not displaying)
    pls help me....
    Rohitha

    I'm newbie to JSF. I want to add dynamic menu to my page. and when click on a menu Item in the same page I want to display corresponding page. So, I tried to use jsp:include tag to display the page.
    <f:subview id="myMenu">
                <t:jscookMenu layout="hbr" theme="ThemePanel" >
                    <t:navigationMenuItems value="#{dynMenu.navItems}" />
                </t:jscookMenu> 
    </f:subview>     
    <f:subview id="midPage" rendered="#{dynMenu.pageUrl != null}">          
              <jsp:include page="customer.jsp"/>
    </f:subview>but when I use this way Menu is not displaying
    If I remove <jsp:include page="customer.jsp"/> then menu is displaying.
    (in the page If I use jsp:include tag any where, the menu is not displaying)
    pls help me....
    Rohitha

  • JSP include problem

    I am facing problems with the JSP include functionality in my project.
    What I want to do is to include jsp files on the fly i.e depending on the business need I should be able to swap in and out jsps from the main jsp.
    I plan to do this by feeding the file names in a request attribute and then including the files in the order given.
    But on using the jsp:include there is no output generated by the included jsp.
    There is no error either in the log or in the page directly.
    Please help me in finding out what exactly is the issue here.
    the files are index.jsp --> rightRailIncludeFiles.jsp --> dynamically loaded jsps (These may themselves contain other included files)
    index.jsp
    <div id="right" class="testRight">
        <%@ include file="rightRailIncludeFiles.jsp" %>
    </div>
    rightRailIncludeFiles.jsp
    <%
        out.println("<h1>Dyna Include</h1>");
        String fileNames = (String)request.getAttribute("jspFiles");
        String[] fileList = fileNames.split(",");
        out.println("<!-- Files : " + fileNames + " -->");
    %>
    <%
    for(int i=0;i<fileList.length;i++) {
        try {
             out.print("<!-- "+fileList[i]+" -->");
    %>
        <jsp:include page="<%=fileList%>" flush="true"/>
    <%
    } catch(javax.servlet.ServletException e) {
    out.println("<h3 style=\"color:red\"> Error :"+e.getMessage()+"</h3>");
    %>
    *inlude_1.jsp (This file includes another file which has some common code)*<jsp:include page="include/inlude_1.jsp" flush="true">
    <jsp:param name="magicNumberText" value="${request.adMagicNumberText}" />
    <jsp:param name="setType" value="${request.adSetType}" />
    <jsp:param name="width" value="${request.adWidth}" />
    <jsp:param name="height" value="${request.adHeight}" />
    <jsp:param name="adOuterDivClass" value="${request.adOuterDivClass}" />
    </jsp:include>
    Edited by: danbrown on Feb 9, 2009 2:49 AM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    Good morning,
    I am not sure that could be the real problem , but I guess your app server does not like the fact that you broke the try catch in two parts. In any case, you should not do that :) Mixing code and display is very painful for maintenance :)
    Have you tried to remove the jsp:include and see if the output is correctly produced?
    Best Regards
    Edmondo

  • Paths in JSP Includes

    I can successfully use a JSP Include line in my code if the included file is in the same folder as the code, but all attempts to point to another folder on the same server have been unsuccessful.
    I need to go "up" four levels and then down three in another directory. I've tried using "..\..\" and also going out to the root and then down - no luck.
    Example: my code is in C:\abc\def\ghi\jkl\mno and I need to include a file in C:\pqr\stu\vwx
    Any help would be appreciated. Thanks.

    that folder needs to be in your web project's context root.
    for Example, assume that your web project name is myWeb ( also is the folder Name)
    Here your project root is myWeb, and you can only inlude any JSP under myWeb folder, not out side of it.
    c:\java\projects\myWeb\jsp\
    and you have sub folders under jsp
    c:\java\projects\myWeb\jsp\accounts\
    c:\java\projects\myWeb\jsp\personal
    c:\java\projects\myWeb\jsp\finance

  • How to Parse Escape Character(&) with JSP Include URGENT

    Hi,
    I guess anyone could help me out.
    I have a JSP file where I am including another JSP file and setting parameter for that include file. Among those parameters one of the parameter is having a value having ampersand with it. like R&D. In such case am i getting following error.
    I dont know how should I get rid of this &.
    I tried converting it to amp; even tried \\& also tried using escape("R&D"). But no success. Can you guys help
    Code:
    <jsp:include page="../hottopics/controller_hottopics1.jsp" flush="true">
    <jsp:param name="UserID" value="<%=username%>" />
    <jsp:param name="kmsid" value="<%=kmsid%>" />
    <jsp:param name="department" value="<%=department%>"/>
    <jsp:param name="location" value="<%=location%>"/>
    <jsp:param name="supportorg" value="<%=supportorg%>"/>
    <jsp:param name="supportflag" value="<%=supportflag%>"/>
    </jsp:include>
    department : R&D
    Error :
    java.lang.IllegalArgumentException
    at javax.servlet.http.HttpUtils.parseQueryString(HttpUtils.java:151)
    at org.apache.tomcat.facade.RequestDispatcherImpl.addQueryString(RequestDispatcherImpl.java:546)
    at org.apache.tomcat.facade.RequestDispatcherImpl.doInclude(RequestDispatcherImpl.java:388)
    at org.apache.tomcat.facade.RequestDispatcherImpl.include(RequestDispatcherImpl.java:270)
    at org.apache.jasper.runtime.PageContextImpl.include(PageContextImpl.java:414)
    at ITHelpAlerts_0002dv_00034._0002fITHelpAlerts_0002dv_00034_0002fgadget_0002ejspgadget_jsp_7._jspService(_0002fITHelpAlerts_0002dv_00034_0002fgadget_0002ejspgadget_jsp_7.java:210)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:119)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at org.apache.jasper.servlet.JspServlet$JspCountedServlet.service(JspServlet.java:130)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:282)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:429)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:500)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:405)
    at org.apache.tomcat.core.Handler.service(Handler.java:287)
    at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
    at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:812)
    at org.apache.tomcat.core.ContextManager.service(ContextManager.java:758)
    at org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpConnectionHandler.java:213)
    at org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416)
    at org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:501)
    at java.lang.Thread.run(Thread.java:534)

    Okay, not surprising. Like I said, the & has special meaning in URLs, to seperate one parameter from the next. Perhaps you should thing about using request attributes instead of parameters:
    request.setAttribute("department", "R&D");
    //then on recieving side
    String department = (String)request.getAttribute("department");

  • JSP:Include directive - can I access data?

    Hi,
    I am using the 'include' directive (either jsp:include method or <%@ include.... /> ) to include another jsp page.
    I want the included file to access variables that have been set up in the main page (the one with the include directive in it). I've tried several things, including setting up a Bean class, but nothing seems to work
    Is this possible? I really appreciate any help with this.
    Thanks.

    You cannot use <%@ include ..%> because that is resolved at translation time. <jsp:include /> is resolved dynamically and should give you what you need. In the main page, store references to the bean or other data as request attributes and then retrieve them in the included page.

  • Unable to run jsp as include using jsp:include tag

    I am trying to run the basic jsp:include sample provided by Oracle in OC4J 10g. When I run the code, It seems like include file is treated as text/html and not run at all. Can somebody help me in figuring out what I am missing here..
    Here is the code for main.jsp
    <jsp:include page="content.jsp">
    <jsp:param name="a" value="1"/>
    <jsp:param name="b" value="2"/>
    <jsp:param name="c" value="3"/>
    </jsp:include>
    Here is the code for content.jsp
    <p> Included Content </p>
    <p> Parameters - ${param.a}, ${param.b}, ${param.c} </p>
    When I run this code in JDeveloper10g using the embedded OC4J as well as Application Server 10g, I get the following output.
    Included Content
    Parameters - ${param.a}, ${param.b}, ${param.c}
    Note that the parameter values are not substituted properly.
    Thanks in advance
    Niraj

    javax.servlet.ServletException: com/sun/tools/javac/Main (Unsupported major.minor version 49.0)
    This is your problem either your tomcat or eclipse is pointing to a wrong jre
    here the problem is you are trying to run a code that was compiled using j2sdk1.5 in j2sdk1.4

  • A peculiar problem using jsp:include conditionally

    Hi,
    This is regarding usage of jsp:include in Myfaces 1.1.4.
    lets say the page containing the jsp:include statements as PARENT PAGE
    I have a requirement to display some components in the PARENT PAGE which are continued from the same form using different JSPs since the components are different based on a condition.
    I used the following code:
    <h:panelGrid id="CandidateRequestorView" rendered="#{RgsViewRequirementBB.displayCandidateView}" columns="1">
         <jsp:include page="/RGSPages/requestorViewReq.jsp"/>
    </h:panelGrid>
    <h:panelGrid id="CandidateMatcView" rendered="#{!RgsViewRequirementBB.displayCandidateView}" columns="1">
         <jsp:include page="/RGSPages/matcViewReq.jsp"/>
    </h:panelGrid>Now if I use only 1 panel grid (any one out of the above 2) it works. I didnt even use <f:subview> any where( neither in the PARENT PAGE nor in the included jsps), but it works.... Also for your knowledge these jsps contain only JSF elements( no plain HTML code is used)
    But if I am using the above displayed code to have both the jsps (actually only one will be displayed bcoz the same condition is used)
    then its not displaying all the contents of included jsp. (YES I AM ABLE TO GET TO THE JSP...THERE IS NO ERROR) There is a datatable inside this jsp which is not rendered......
    I have used <f:subview> when i faced this problem.......
    I have tried every combination....writing <f:subview> in the PARENT PAGE ....writing in included jsps and removed it from PARENT PAGE.....also some of the articles in the forum mentioned that <f:subview> element should not be used inside <h:panelgrid> .....i even tried that....but final result is same as I was getting the first time...
    I am able to reach the jsp page (with or without <f:subview>) but i am not able to display all the contents....but if i use only one of the included jsps(by removing any one of the panel grids) I am able to view them. Since I am able to view all the contents when i view these pages inside the PARENT PAGE one at a time, that indicates there is no problem in datatable contained in these pages.....
    ( Also I have not used <f:view> inside my included jsps.)
    Please help to solve this problem...
    Thanks
    Avner

    Hi BalusC,
    The RgsViewRequirementBB is already in the session scope.
    Also I am using the setDisplayCandidateView(true) or setDisplayCandidateView(false ) explicitly as depicted below. The page is still under construction thats why the rendered attribute is explicitly set.
    public RgsViewRequirementBackingBean() {
    super();
    // TODO Auto-generated constructor stub
    try{
                setDisplayCandidateView(true);
                 // some more code goes in here
         catch(Exception){
               ResourceBundle bundle = null;
               bundle = ResourceBundle.getBundle("resources.ErrorMessages", FacesContext.getCurrentInstance().getViewRoot().getLocale());
                 //some more code goes in here
    }

  • jsp:include in JSF

    Hello all,
    I am having a problem including a jsp page into another jsp where both are using the JSF framework.
    If I used the <f:view> and bring up just that page by itself (not included in another page), it works fine. And if I include it in a page with no <f:view> tags, it works fine. But when I include it in a page with <f:view> tags and <f:subview> tags in the included page, it's like it pulls the JSF components out of the section of code it was in. I don't know if this is a bug or just something I'm doing incorrectly, but I don't understand why JSF needed to make page includes so difficult.
    My current setup is like this.
    A.jsp
    <taglibs>
    <html>
    <body>
    <table>
    <f:view>
    <h utputText />
    .........more code......
    </f:view>
    <jsp:include page="B.jsp" flush="false" />
    </table>
    </body>
    </html>
    B.jsp
    <taglibs>
    <% scriptlet %>
    <f:subview>
    <h:form>
    <table>
    ...Some table stuff...
    <tr>
    <td>
    <h:commandLink /> (this is what is not working)
    </td>
    </tr>
    </table>
    </h:form>
    </f:subview>
    Hopefully someone can look at this and give me some advice on how to structure the <jsp:include>, I've tried all sorts of things. I've tried subview in different ways to no avail. Thanks for the help.
    Patrick

    here is a sample JSP
    <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
    <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
    <f:view>
    <f:verbatim>
    <html>
    <body>
    <table width="100%" cellspacing="0" cellpadding="0">
         <tbody>
         <tr>
              <td>
                   </f:verbatim>
                   <f:subview id="header">
                        <jsp:include page="<%=(String) request.getAttribute("header")%>"/>
                   </f:subview>
                   <f:verbatim>
              </td>
         </tr>
         </tbody>
    </table>
    </body>
    </html>
    </f:verbatim>
    </f:view>

Maybe you are looking for