Win a copy of Java Concurrency Live Lessons this week in the Threads forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

include mechanism problem  RSS feed

 
mike mimmis
Ranch Hand
Posts: 57
Java MySQL Database Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use Frame instead of including pages(Header and Footer) in every page. It will solve your problem.
 
Tarun Bolla
Ranch Hand
Posts: 89
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 246
Firefox Browser Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using J-Developer 11 it has that facility to replace the file name when you change the file name.
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
mallikarjun dontamsetti
Ranch Hand
Posts: 246
Firefox Browser Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Most IDEs will do this (eclipse, IntelliJ, and so on).
 
mallikarjun dontamsetti
Ranch Hand
Posts: 246
Firefox Browser Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is eclipse update the reference when i rename the file name?
 
mike mimmis
Ranch Hand
Posts: 57
Java MySQL Database Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

Thanks for your valuable suggestions. Now I can solve this issue with your suggestions.

Thanks and Regards,
mike
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!