Does any one tell me that,
when eclipse run how to load index.jsp on server ,
when i run server the index.jsp should be reflect but it not reflecting
You do this using the web.xml file which is stored in the WEB-INF folder
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">
<display-name>Welcome to Tomcat</display-name>
<description>
hello
</description>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
Here the welcome-file is the file you want to load on the server startup..
Hope this helps
Related
I have a java .war application and I deployed on Tomcat.
I looked for a way to know all the urls that respond under the "localhost:8080" path.
The solution may not be strictly linked with tomcat or java, it could be a browser option or other tools like a url mapper.
Do you have any suggestion?
UPDATE: the /WEB-INF/web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<display-name>notificationcardtrx-webapp</display-name>
<!-- Changing the default timeout so now the workstation use the same H2O timeout -->
<session-config>
<session-timeout>120</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
I used eclipse and tomcat and created a dynamic web project following this tutorial:
https://o7planning.org/en/10169/java-servlet-tutorial
I followed all the steps until running the code for the first time to display 'Hello, World!' on a webpage, but it gave the following error. I have added index.html properly.
What could be the issue? Yesterday I created another dynamic project in the same workspace that the simple project was run it, but it's not working either. Could it be a port issue?
HTTP Status 404 – Not Found
Type Status Report
Message /ServletFirstTutorial/
Description The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.
Apache Tomcat/9.0.14
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
id="WebApp_ID" version="3.0">
<display-name>ServletFirstTutorial</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
</web-app>
I am trying to map my compiled jsp class which is available in org.apache.jsp folder in tomcat server folder to the web.xml file so that I don't want to ship my jsp code.
I am using following code, but getting HTTP Status 404 -. I cross checked, paths are correct and class files are also available in that path I don't know why i am getting this error.
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<servlet>
<servlet-name>org.apache.jsp.index_jsp</servlet-name>
<servlet-class>org.apache.jsp.index_jsp</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>org.apache.jsp.index_jsp</servlet-name>
<url-pattern>/index.jsp</url-pattern>
</servlet-mapping>
</web-app>
Can any one help me to fix this?
you must use jsp-file tag for jsp mapping in web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<servlet>
<servlet-name>org.apache.jsp.index_jsp</servlet-name>
<jsp-file>org.apache.jsp.index_jsp.jsp</jsp-file>
</servlet>
<servlet-mapping>
<servlet-name>org.apache.jsp.index_jsp</servlet-name>
<url-pattern>/index_jsp.jsp</url-pattern>
</servlet-mapping>
I have a j2ee app running on GAE. There is that pre-generated index.html, which is called every time I run the server - let's say http://localhost:8080. But I want to write my own front-end using AngularJS. For that, I created the whole project with Yeoman and copied all the files to folder in my j2ee project.
Right now -> I can call manually the AngularJS webapp like this: http://localhost:8080/webapp/app/index.html
But obviously, that is not the way one wants to go. I would like to call it simply on http://localhost:8080. How can I achieve this?
So it took me longer than expected, but here's how I got it working using the welcome file:
Here's my folder structure:
web.xml file:
<?xml version="1.0" encoding="utf-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">
<servlet>
<servlet-name>So123</servlet-name>
<servlet-class>so123.So123Servlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>So123</servlet-name>
<url-pattern>/so123</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>webapp/app/index.html</welcome-file>
</welcome-file-list>
</web-app>
Hope this helps.
https://developers.google.com/appengine/docs/java/config/webxml#The_Welcome_File_List
You can also change the root directory in the appengine-web.xml file. Full documentation here.
<public-root>/app</public-root>
I want to have a dedicated directory for jsp and servlet development, but I can't map my app's logical name resource correctly. I tested the app without the extra directory as follow:
C:\tomcat1\webapps\beer-v1
The app ran successfully. But if I map the application to(my desired location):
C:\tomcat1\webapps\dev\beer-v1
The application does not run. I get a 404 error, resource not found. The following is my web.xml file.
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
<servlet>
<servlet-name>Ch3 Beer</servlet-name>
<servlet-class>com.example.web.BeerSelect</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Ch3 Beer</servlet-name>
<url-pattern>/SelectBeer.do</url-pattern>
</servlet-mapping>
</web-app>