• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to add HTML tags to Response Servlet

 
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1. I have a ServletFilter which would intercept all requests (/*).
2. I need to add a hyperlink HTML tag, to the requested page.

So, that I need to have this link across all pages of my application., essentially I am trying avoid the 'href' in each page.

Please help ..

Thanks,
Shinelin
 
Ranch Hand
Posts: 650
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Doesn't that servlet filter mean that all requests to your application will go through your servlet? How will you serve your JSP view pages?

As far as your href goes, I'm afraid I can't understand what you're asking. Perhaps you can provide some more details?

 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It sounds like using a filter for this is not a particularly good idea.

As Mark asked, please elaborate on what you are trying to do. It may be that a custom tag is what you need.
 
Shinelin Samuel
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Bibeault & Mark for your interest..

Here is what I need, the below is my Index.jsp, it has a link to Page2.jsp, similiar case there are other JSPs in my project.

I need to have a link on Right end of each page (similiar to Header/Footer links we see in any webpage), without making any code in Index.jsp or Page2.jsp.

I think we can do this in Struts or JSF, please let me know if there are any other ways without using APIs.



 
Mark E Hansen
Ranch Hand
Posts: 650
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are you saying you want to have a similar header and footer on all pages?

Why not create header/footer JSP files, and just include them in all your pages. Then, you can edit the single header.jsp file, for example, and it will affect all pages that include it.

I can't imagine an easy way to do this with filters, so I think I'll let someone else help with that.
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Filters cannot be used.

If you cannot change the JSP files, this simply cannot be done.
 
Shinelin Samuel
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It is not exactly headers/footers. Actually I am developing an API which will be available in all pages, it can be accessed by the link I mentioned earlier.

The question is about how easy my API can be plugged-in or integrated with different applications ? (that why I was not leaning towards any MVC APIs) {sounds little bit too much, expectation on Technology }

Since the Servlet response object contains the HTML of the loading page, I thought it can be edited using the PrintWriter methods [(.write() / .append()) which did not help my purpose] or any other means.

I think I should go for Struts-Tiles or JSF or include in each JSP, I am still open to any other suggestions

Thanks again for your inputs !!
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just create a custom tag and be done with it. Why on Earth would you need Struts or JSF?
 
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
According to my understanding the simplest way is create header/footer jsp file and include in all jsp file.
Second way is create a custom tag and use that in any jsp file. But in both case you need to modify the existing jsp file.
If you go for struts/tiles framework you can include header/footer without modifying existing jsp pages.
The most complex way is to use filter, this may be possible if you use servlet only, in case of jsp file filter may bot work.
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you just want to prepend and append you can use a prelude and coda -- which you can do simply with the deployment descriptor. If you are trying to insert something inside the body of the HTML... that's a whole 'nother country.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic