| Author |
include mechanism problem
|
mike mimmis
Ranch Hand
Joined: Feb 11, 2011
Posts: 56
|
|
Dear Ranchers,
I have a small doubt but I could not able to find a solution for it. Please help me regarding this issue.
Issue: in my web application there are nearly 40 JSP pages all JSP pages with same header and footer. So I have designed 2 jsp pages like
1. header.jsp
2. footer.jsp
What I have done is I have included this two pages in my all 40 JSP pages with following mechanism
It is working fine but what is my problem is whenever I want to rename the header.jsp or footer.jsp to other names I have to change the file names in all my 40 JSP pages.I want avoid changing the same file names in 40 pages. Is there any solution for this problem.
Please reply me as soon as possible.
Thanks and Regards,
mike......
|
 |
mac dn
Greenhorn
Joined: Jan 15, 2012
Posts: 3
|
|
|
Use Frame instead of including pages(Header and Footer) in every page. It will solve your problem.
|
 |
Tarun Bolla
Ranch Hand
Joined: Jun 20, 2011
Posts: 85
|
|
Hi mike,
I havent tested the approach but here is a possible solution
Create a Constants file..Say Some AppConstants.java which contains final strings for configuration purposes
Now in your jsp you can write
That way you need to change the header page url at one location...in your AppConstants.java
|
 |
Bear Bibeault
Author and opinionated walrus
Marshal
Joined: Jan 10, 2002
Posts: 50693
|
|
Frames are a poor approach. They are rarely used in modern web apps and are deprecated in HTML5.
Sounds like all you need is a good source code editor that can do a replace across all files in a project.
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
Bear Bibeault
Author and opinionated walrus
Marshal
Joined: Jan 10, 2002
Posts: 50693
|
|
Tarun Bolla wrote:
<jsp:include page="<%= AppConstants.HEADERPAGEURL %>" />
Scriptlets are 10 years out of date and should never be used in JSP pages written after 2002. Besides, that's hardly a general solution for markup for the header and footers.
|
 |
mallikarjun dontamsetti
Ranch Hand
Joined: Mar 18, 2011
Posts: 177
|
|
|
I am using J-Developer 11 it has that facility to replace the file name when you change the file name.
|
 |
Seetharaman Venkatasamy
Bartender
Joined: Jan 28, 2008
Posts: 4503
|
|
mallikarjun dontamsetti wrote:I am using J-Developer 11 it has that facility to replace the file name when you change the file name.
Ohh. cool even eclipse has it! Alt+shift+R
|
Not everything that counts can be counted, and not everything that can be counted counts-Albert Einstein
|
 |
mallikarjun dontamsetti
Ranch Hand
Joined: Mar 18, 2011
Posts: 177
|
|
Seetharaman Venkatasamy wrote:
mallikarjun dontamsetti wrote:I am using J-Developer 11 it has that facility to replace the file name when you change the file name.
Ohh. cool even eclipse has it! Alt+shift+R
In eclipse it ask for only rename of the file but in J-Developer if you click rename it ask's like this "rename the file and update the references" when you say yes it updates the reference location also.
|
 |
Bear Bibeault
Author and opinionated walrus
Marshal
Joined: Jan 10, 2002
Posts: 50693
|
|
|
Most IDEs will do this (eclipse, IntelliJ, and so on).
|
 |
mallikarjun dontamsetti
Ranch Hand
Joined: Mar 18, 2011
Posts: 177
|
|
|
Is eclipse update the reference when i rename the file name?
|
 |
mike mimmis
Ranch Hand
Joined: Feb 11, 2011
Posts: 56
|
|
Hi all,
Thanks for your valuable suggestions. Now I can solve this issue with your suggestions.
Thanks and Regards,
mike
|
 |
 |
|
|
subject: include mechanism problem
|
|
|