Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
The moose likes Servlets and the fly likes Generating dynamic includes with servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Generating dynamic includes with servlet" Watch "Generating dynamic includes with servlet" New topic

Generating dynamic includes with servlet

Marek Krokosinski
Ranch Hand

Joined: Jun 10, 2011
Posts: 64

I'm trying to code my first administration panel, and I have JSP page with menu:

And I have a servlet:

I want to make something like this: When I will click "add" menu item, servlet gets parameter "category" and "action" and it generates an request attribute with jsp:include or c:import (or only path for the included file).
<jsp:include> is executed at runtime right? So passing the "<jsp:include page="data/blog/add.jsp" /> to the parameter and retriving it in the jsp page is senseless and it doesn't work. When I'm trying to pass only path to the included file and my administration page is not even displaying, I see only index page.

I tried something similar with the c:import. I saved "<c:import url="/data/blog/add.jsp" />" in request parameter and I retrived it in the jsp page, but of course it didn't work. I didn't try to save path to the file in request parameter and retrive it in the <c:import> tag, because it doesn't accept EL.

My question is, how to make the JSP page to be a based on request attributes? If theres a category=blog action=add attributes, the page should display form which allows for adding new blog entry. Is it possible?

It's hard for me to explain this, but I hope you will understand :>

Best Regards.

I agree. Here's the link:
subject: Generating dynamic includes with servlet
It's not a secret anymore!