الطريقة الأولى: (مناسبة لإعداد موقع واحد في الخادم)
(d:demo هو الدليل الجذر للموقع)
في Tomcat، الصفحة الرئيسية الافتراضية هي: Index.html، وindex.htm، وindex.jsp
إذا كنت بحاجة إلى استخدام صفحة أخرى كصفحة رئيسية افتراضية، فستحتاج إلى تكوين ملف web.xml في المجلد WEB-INF:
كما في المثال أعلاه:
قم بإنشاء الملف web.xml في المجلد D:demoWEB-INF:
المحتوى هو كما يلي:
<?xml version=”1.0″ encoding=”UTF-8″?>
<إصدار تطبيق الويب=”2.4″
xmlns =”http://java.sun.com/xml/ns/j2ee”
xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance”
xsi:schemaLocation=”http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd ">
<قائمة ملفات الترحيب>
<welcome-file>hello.jsp</welcome-file>
</welcome-file-list>
</web-app>
الطريقة الثانية: (ستنطبق الإعدادات التالية على جميع المواقع الموجودة ضمن هذا الخادم) يوصى بفتح الملف conf/web.xml والعثور على هذا الرمز:
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
فقط أضف اسم الملف الذي تريده في المنتصف.
على سبيل المثال: أريد أن يكون hello.jsp هو الصفحة الرئيسية الافتراضية، وقمت بتغيير الكود أعلاه إلى:
<welcome-file-list>
<welcome-file>hello.jsp</welcome-file>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>