Web applications 在web应用程序中使用欢迎文件的最佳方法

Web applications 在web应用程序中使用欢迎文件的最佳方法,web-applications,servlets,Web Applications,Servlets,我有一个Tomcat应用程序,可以选择在web.xml文件中列出欢迎(或索引)页面,如下所示: <welcome-file-list> <welcome-file>/jsp/user/index.jsp</welcome-file> </welcome-file-list> <servlet> <servlet-name>IndexServlet</servlet-name> &l

我有一个Tomcat应用程序,可以选择在web.xml文件中列出欢迎(或索引)页面,如下所示:

<welcome-file-list>
       <welcome-file>/jsp/user/index.jsp</welcome-file>
</welcome-file-list>
<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>

/jsp/user/index.jsp
并使用scriptlet调用数据库方法来填充页面

或者,我可以使用servlet调用一个或多个欢迎页面,如下所示:

<welcome-file-list>
       <welcome-file>/jsp/user/index.jsp</welcome-file>
</welcome-file-list>
<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>

IndexServlet
myApp.misc.Index_Servlet
IndexServlet
/IndexServlet
IndexServlet
无论选择哪种方式,欢迎页面都需要显示大量数据以呈现少量可视化。但是欢迎页面不需要进行用户身份验证

有人能告诉我这些选项中的一个比另一个好吗

谢谢


摩根先生。

没有一个比这更好


尝试将视图与逻辑分离()。不要将Scriptlet放在jsp中。

我不喜欢Scriptlet,但无论如何,MVC都将通过servlet方法使用,servlet将通过数据库方法调用设置会话变量。这些将由使用图像标记从servlet调用的JSP读取。