Hello,
I am writing a
java webapp using JSP/Servlets and am looking for a little help regarding implementing something in a best practice approach. Here are the steps in my program:
1) User logs in to index.jsp
2) User goes to display.jsp
3) display.jsp opens XML file and displays it.
I initially thought that from within "display.jsp" I could call a bean (
jsp:useBean) and have it return Objects from the XML file. The issue with this is that my XML file is included within my web application, so I do not want to hardcode the location to the XML file (as this could change depending on where it is deployed). I would be able to get past this by passing the realpath to the Bean, like:
<% myBean.setPath( getServletContext().getRealPath("") ); %>
This however seems like its not the way I should be doing it. So I decided to look up how other people have done this, and most examples seem to point to submitting to a
servlet, and having it pass the path to the Bean, then forwarding to a jsp page. This however confuses me, since the way I am writing this I only have a "JSP" page which should display this, no forms etc.
Can anyone please help me determine how I should implement this?
Thanks a lot!