I have a Tomcat application where I have the choice to list the welcome (or index) page in the web.xml file as follows:
<welcome-file-list>
<welcome-file>/jsp/user/index.jsp</welcome-file&开发者_JAVA技巧gt;
</welcome-file-list>
And use scriptlets to call database methods to populate the page.
Or I can use a servlet to call a welcome page or pages as follows:
<servlet>
<servlet-name>IndexServlet</servlet-name>
<servlet-class>myApp.misc.Index_Servlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>IndexServlet</servlet-name>
<url-pattern>/IndexServlet</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>IndexServlet</welcome-file>
</welcome-file-list>
Whichever way is chosen, the welcome page will be required to display quite a lot of data to render a small number of visualisations. But the welcome page won't be required to do user authentication.
Can anyone tell me if one of these options better than the other or not?
Thanks
Mr Morgan.
None of them is better.
Try to separate your view from your logic (MVC). Do not put scriptlets in your jsp, instead use taglibs and custom taglibs.
精彩评论