views:

25

answers:

1

Hello

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>
</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.

A: 

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.

Redlab
I dislike scriptlets but MVC would be employed via the servlet approach anyway where the servlet will set session variables from the database method calls. These will be read by the JSP called from the servlet using image tags.
Mr Morgan