I want to create tabs within my Struts application where once a tab is selected, there will be navigation links down one side, and when links are selected, the remainder of the tab area will serve as the "workspace" for displaying the corresponding JSP page. I have tried using the struts-display tag library and have been able to generate tabs and panels for my links, but I'm not sure how to direct the jsp output to a specific panel in a tab.
Is there a better method to do this? I would like some possible suggestions on ways of accomplishing this that has ample documentation. I know this is a very common design these days, so I know there has to be a better way (or at least one with more documentation than struts-display library). Just looking for suggstions on technologies/frameworks that I could start investigating.
All my jsp files are kept in Tomcat under the /WEB-INF/jsp/ directory. Do I need to do anything differently? Usually I can just put the path from web app root directory to jsp directory and the app can find the files. Why is this different?
Servlet containers do not allow web access to files under the WEB-INF directory.
In and MVC environment (such as with Struts), you typically forward to any JSPs. The browser is not requesting them directly. To preserve your MVC archetecture, create a controller servlet that forwards to these JSPs using a requestDispatcher. Otherwise, move the JSPs out from under WEB-INF. [ May 19, 2006: Message edited by: Ben Souther ]
In my application, I have an action servlet that dispatches to one jsp, but now with iframes, that jsp page contains two iframe tags that both point to separate jsp pages. So, I'm dispatching to one jsp file that needs to refrence two other jsp files contained in iframe tags.
I hope I'm following your advice correctly. If not, please point me to some reference material on this type of thing. I'm just looking for a simple example (with code snippets).
Lets say you have one controller for the app. Set up one mapping that grabs any requests that end with ".do"
Now, lets suppose you have 3 JSPs (a frameset, a menu, and a main page) Your framset (index.do) will have two frame tags:
Now in your controller, write code that analyzes the URI and forwards to the proper JSP according to the URI
When you hit the initial page, the servlet will forward to the index.jsp (your frameset page) page. Once the page loads in the browser, the browser will fire off two new requests, one for the menu and one for the main page. The controller will analyze each of these requests and forward to the correct JSP.
Ok, I have one last question. When I try and add the frameset tags into my jsp (my tab actually) I don't see any output at all. I would at least expect to see empty frames or frames with the "Page not found" error, but I don't see the outlines of the frames at all. Here's my main display page:
Where the controller forwards the display.do to a jsp page which lists my links. What's interesting is that when I was playing around with the iframe tag, I was getting it to display, but when I switched to the frame tags, I see nothing - just an empty tab. I really like the functionality of the frame tag as opposed to iframes.
Do you know if there are any known issues with having frameset and frame tags within a display:tab tag?