| Author |
setting title in web.xml
|
Aravind Prasad
Ranch Hand
Joined: Dec 28, 2005
Posts: 258
|
|
Dear Ranchers, I'm doing a project in JSP and MySQL. In each and every page, instead of giving the title for the html page, is there any way to put the title in web.xml, so that Even if I want to change the title, i can just edit in the web.xml, so that it can reflect other pages also.. Please help me with your enriched ideas. Regards Aravind Prasad
|
 |
Chris Corbyn
Ranch Hand
Joined: Jan 14, 2007
Posts: 114
|
|
I create screen.xml files for this... one per-screen in, for example /WEB-INF/screens/documentation/contents.xml: Now just use XPath to query what you need. I have a ScreenFactory object which creates a simple bean from the configuration. I also store 'fragments', CSS files, JS files and Meta data in here.
|
 |
Aravind Prasad
Ranch Hand
Joined: Dec 28, 2005
Posts: 258
|
|
Dear Chris, Thanks for the reply.. But Can you please make it clear.. I will create scree.xml file in WEB-INF and then how will i call in the index.jsp page.? Please explain for me in details with some sample codings if you can. Regards Aravind Prasad
|
 |
Ben Souther
Sheriff
Joined: Dec 11, 2004
Posts: 13410
|
|
One simple way to do this is to create a context init param in web.xml and use that for your title. Are you familiar with context-init params?
|
Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56152
|
|
I'd avoid setting up something proprietary to do this. Either use context parameters as Ben suggested, or if you need something a little robust, properties files with the JSTL fmt tags.
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
Aravind Prasad
Ranch Hand
Joined: Dec 28, 2005
Posts: 258
|
|
Thanks for the reply.. I'm not that much familiar with Context init params. Please send me a sample code for that. Thanks/Regards Aravind Prasad
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56152
|
|
Context init params can be used in the EL via the initParam builtin map: ${initParam.pageTitle} Setting one up in the web.xml is as easy as: [ September 10, 2007: Message edited by: Bear Bibeault ]
|
 |
Aravind Prasad
Ranch Hand
Joined: Dec 28, 2005
Posts: 258
|
|
Thankyou Bear, I have done the script like this WEB-INF\web.xml In the index.jsp page I have done like this index.jsp But I'm getting the following Error messagem when i run the program Please help me, to find a solution for this Regards Aravind Prasad
|
 |
Muhammad Saifuddin
Ranch Hand
Joined: Dec 06, 2005
Posts: 1318
|
|
EL (Expression Language) is must configured in your web.xml file in order to using it jsp pages. this url will help you to configure it.. ServletsWebXml hope it helps.. [ September 11, 2007: Message edited by: Saif uddin ]
|
Saifuddin..
[Linkedin] How To Ask Questions On JavaRanch My OpenSource
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56152
|
|
<title> <% ${initParam.pageTitle} %> </title>
You do not use <% and %> when using the EL.
|
 |
Aravind Prasad
Ranch Hand
Joined: Dec 28, 2005
Posts: 258
|
|
Dear Mr.Bear, Thanks for the reply.. Even if i'm not using the <% and %>.... I'm getting te error message.. Please advise.. Regards Aravind Prasad
|
 |
Ben Souther
Sheriff
Joined: Dec 11, 2004
Posts: 13410
|
|
|
What error message are you getting now?
|
 |
Aravind Prasad
Ranch Hand
Joined: Dec 28, 2005
Posts: 258
|
|
Dear Ben, The error I'm getting is here Please advise.. whether i've put anything wrong!! Regards Aravind Prasad
|
 |
Ben Souther
Sheriff
Joined: Dec 11, 2004
Posts: 13410
|
|
Post your whole JSP (now that you've updated it) and let us know what line 4 is.
|
 |
 |
|
|
subject: setting title in web.xml
|
|
|