• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

setting title in web.xml

 
Aravind Prasad
Ranch Hand
Posts: 265
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 114
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 265
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64718
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Aravind Prasad
Ranch Hand
Posts: 265
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64718
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 265
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1324
Android Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64718
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<title>
<% ${initParam.pageTitle} %>
</title>


You do not use <% and %> when using the EL.
 
Aravind Prasad
Ranch Hand
Posts: 265
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What error message are you getting now?
 
Aravind Prasad
Ranch Hand
Posts: 265
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Ben,
The error I'm getting is here



Please advise.. whether i've put anything wrong!!

Regards

Aravind Prasad
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Post your whole JSP (now that you've updated it) and let us know what line 4 is.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic