Results 1 to 4 of 4

Thread: dynamically change page content

  1. #1

    Thread Starter
    Hyperactive Member Greyskull's Avatar
    Join Date
    Dec 2003
    Location
    somewhere in England
    Posts
    382

    dynamically change page content

    Hello,

    Im starting to learn a few things with JSP and here is my current situation:
    I have several jsp pages linked together namely: header, menu, content and footer.
    Each item in the menu should be associated with a different content i.e menu1content.jsp, menu2content.jsp, etc...
    I have created an ant files to build and compile the jsp pages to a .war file and run it using Tomcat.
    The question is, how would i do it so that whenever a link is clicked on the menu, the content of the page dynamically changes. i.e when link 1 is clicked it automatically assigns menu1content.jsp to the page?

    Here is my main layout (baselayout.jsp)

    Code:
    <%-- Include common set of tag library declarations for each layout --%>
    <%@ include file="/WEB-INF/jsp/common/taglibs.jsp"%>
    
    <html>
        <head>
            <title>
                <tiles:getAsString name="title" ignore="true"/>
            </title>
        </head>
    
        <body>
    	<div align="center">
    	<table width="80%%" border="0" cellpadding="5">
                <tr>
                    <td colspan="2">
    			<tiles:insert attribute="header"/>
    			<hr />
    		</td>
                </tr>
                <tr>
                    <td rowspan="2" width="20%"> 
    			<tiles:insert attribute='menu' ignore="true"/>
                    </td>
                    <td width="80%"><tiles:insert attribute='content' ignore="true"/></td>
              </tr>
                <tr>
                    <td width="80%">
    			<hr />
    			<tiles:insert attribute="footer"/>
    		</td>
              </tr>
            </table>
    	</div>
        </body>
    </html>
    im not sure whether ive explained this right but any help is gr8ly appreciated

    Thanks,
    Please go to the Thread Tools menu and click Mark Thread Resolved when your post is answered
    If someone helped you today then please consider rating their post.

  2. #2
    Arabic Poster ComputerJy's Avatar
    Join Date
    Nov 2005
    Location
    Happily misplaced
    Posts
    2,513

    Re: dynamically change page content

    use the <% %> tags to add add Java code to your page... Or read a little for more help
    "I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
    My Blog

  3. #3

    Thread Starter
    Hyperactive Member Greyskull's Avatar
    Join Date
    Dec 2003
    Location
    somewhere in England
    Posts
    382

    Re: dynamically change page content

    Thanks for the reply, i kinda knew i had to use the <% %> tags but not sure what to put inside it..anyways if it doesnt work how do i instead open another jsp page?

    ive got the following set-up atm

    Code:
    <%@ include file="/WEB-INF/jsp/common/taglibs.jsp"%>
    
    <div>
    	<ul>
    		<li>
    			<a href="http://localhost:8080/HelloWorldTile">Hello World</a>
    		</li>
    		<li>
    			link 2
    		</li>
    	</ul>
    </div>
    not sure what to put in link 2 which will open another jsp page which was compiled in the same war file unlike the first link which has a different war file..

    thanks
    Please go to the Thread Tools menu and click Mark Thread Resolved when your post is answered
    If someone helped you today then please consider rating their post.

  4. #4
    Arabic Poster ComputerJy's Avatar
    Join Date
    Nov 2005
    Location
    Happily misplaced
    Posts
    2,513

    Re: dynamically change page content

    you can use <% %> to write regular Java code.
    Link 2 should be to were apache has mapped the web page, not the war file. War files are only containers (somewhat like jar files)
    "I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
    My Blog

Posting Permissions

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



Click Here to Expand Forum to Full Width