dbaseek
asked on
jsp issue
How can we deploy and execute jsp..
after writing the code in ecclipse..eg I created a jsp named chapt2jsp.jsp under Chapt2
What are the further steps needed to see the output of application.
thanks
after writing the code in ecclipse..eg I created a jsp named chapt2jsp.jsp under Chapt2
What are the further steps needed to see the output of application.
thanks
ASKER
let me try with a small application....
Chapt2 is my project ..In that project I created a a jsp file named Chapt2jsp.jsp
<HTML>
<BODY>
Hello! The time is now <%= new java.util.Date() %>
</BODY>
</HTML>
In the webcontent folder this is the 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" 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" id="WebApp_ID" version="2.5">
<display-name>Chapt2</disp lay-name>
<welcome-file-list>
<welcome-file>index.html</ welcome-fi le>
<welcome-file>index.htm</w elcome-fil e>
<welcome-file>index.jsp</w elcome-fil e>
<welcome-file>default.html </welcome- file>
<welcome-file>default.htm< /welcome-f ile>
<welcome-file>default.jsp< /welcome-f ile>
</welcome-file-list>
</web-app>
Is this right or not
then what is the next step
Chapt2 is my project ..In that project I created a a jsp file named Chapt2jsp.jsp
<HTML>
<BODY>
Hello! The time is now <%= new java.util.Date() %>
</BODY>
</HTML>
In the webcontent folder this is the 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" 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" id="WebApp_ID" version="2.5">
<display-name>Chapt2</disp
<welcome-file-list>
<welcome-file>index.html</
<welcome-file>index.htm</w
<welcome-file>index.jsp</w
<welcome-file>default.html
<welcome-file>default.htm<
<welcome-file>default.jsp<
</welcome-file-list>
</web-app>
Is this right or not
then what is the next step
Hope you created the project structure as i mentioned above.
Remove ur complete welcome file list and replace with this.
<welcome-file-list>
<welcome-file>Chapt2jsp.js p</welcome -file> -- this will work if you place the jsp in the root directory(Chapt2)
</welcome-file-list>
If you have the .jsp somewhere in the folder inside WebContent, then do as below
<welcome-file-list>
<welcome-file>pages/Chapt2 jsp.jsp</w elcome-fil e>
</welcome-file-list>
-deploy in tomcat and access with the specified url and you are good to go.
-Murali*
Remove ur complete welcome file list and replace with this.
<welcome-file-list>
<welcome-file>Chapt2jsp.js
</welcome-file-list>
If you have the .jsp somewhere in the folder inside WebContent, then do as below
<welcome-file-list>
<welcome-file>pages/Chapt2
</welcome-file-list>
-deploy in tomcat and access with the specified url and you are good to go.
-Murali*
ASKER
Mr Murali
What is "pages" here.........it is means what.
<welcome-file-list>
<welcome-file>pages/Chapt2 jsp.jsp</w elcome-fil e>
</welcome-file-list>
What is "pages" here.........it is means what.
<welcome-file-list>
<welcome-file>pages/Chapt2
</welcome-file-list>
pages - is a folder that you can create under webcontent folder. It need not be "pages" you can name anything as you wish. Point here is use the folder name in which u place ur jsp. For now don't confuse just have ur jsp file in the root directory. (i.e) Chapt2 - your project folder
-Murali*
-Murali*
ASKER
Here is the new web.xml under webcontent ..
1,2,5 and 7 lines shows red curvley lines showing error: mouse over shows word correctly not spelled
Is this ok ?
-------------------------- ---------- ---------- ----------
<?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" id="WebApp_ID" version="2.5">
<display-name>Chapt2</disp lay-name>
<welcome-file-list>
<welcome-file>/Chapt2/Chap t2jsp.jsp< /welcome-f ile>
</welcome-file-list>
</web-app>
-------------------------- ---------- ---------- ---------- ---------- -
1,2,5 and 7 lines shows red curvley lines showing error: mouse over shows word correctly not spelled
Is this ok ?
--------------------------
<?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" id="WebApp_ID" version="2.5">
<display-name>Chapt2</disp
<welcome-file-list>
<welcome-file>/Chapt2/Chap
</welcome-file-list>
</web-app>
--------------------------
<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app 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"
version="2.4">
replace ur top web-app tag with this.
<web-app 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"
version="2.4">
replace ur top web-app tag with this.
moreover web.xml should be under ( WebContent/WEB-INF) folder and not directly under ( WebContent) folder.
It is better to try IDE such as Eclipse, Netbeans...
which reduce the time compile and deploy like these things...
ASKER
Sorry one more question when we create Chapt2jsp.jsp it should be under JavaResources:src or webcontent...
ASKER
The reason what I asked you is
this is my jsp code:
<HTML>
<BODY>
Hello! The time is now <%= new java.util.Date() %>
</BODY>
</HTML>
It is in Chapt2 folder ok
Now when I try to run the Chapt2jsp.jsp this message is appearing "cannot find main class program will exit"
What is the reason?
this is my jsp code:
<HTML>
<BODY>
Hello! The time is now <%= new java.util.Date() %>
</BODY>
</HTML>
It is in Chapt2 folder ok
Now when I try to run the Chapt2jsp.jsp this message is appearing "cannot find main class program will exit"
What is the reason?
webcontent
ASKER
If that is the case can you please tell me the reason of the error when I run..
the error is like this
Now when I try to run the Chapt2jsp.jsp this message is appearing "cannot find main class program will exit"
the error is like this
Now when I try to run the Chapt2jsp.jsp this message is appearing "cannot find main class program will exit"
when you run java problem such error comes.
right click jsp and run/deploy on tomcat server
right click jsp and run/deploy on tomcat server
ASKER
I changed the content of the file Chapt2jsp.jsp to the bottom
again same error what is wrong.............
java.lang.NoClassDefFoundE rror: org/apache/juli/logging/Lo gFactory
at org.apache.catalina.startu p.Bootstra p.<clinit> (Bootstrap .java:54)
-------------------------- ---------- ---------- ---------- ---------- ---
<%@ page info="a hello world example" %>
<html>
<head><title>Hello, World</title></head>
<body bgcolor="#ffffff" background="background.gif ">
<table>
<tr>
<td width=150> </td>
<td width=250 align=right> <h1>Hello, World!</h1> </td>
</tr>
</table>
</body>
</html>
again same error what is wrong.............
java.lang.NoClassDefFoundE
at org.apache.catalina.startu
--------------------------
<%@ page info="a hello world example" %>
<html>
<head><title>Hello, World</title></head>
<body bgcolor="#ffffff" background="background.gif
<table>
<tr>
<td width=150> </td>
<td width=250 align=right> <h1>Hello, World!</h1> </td>
</tr>
</table>
</body>
</html>
ASKER
This is the latest error report
-------------------------- ---------- ---------- ---------- ---------- ---------- ----
type Status report
message /Chapt2/Chapt2jsp
description The requested resource (/Chapt2/Chapt2jsp) is not available.
-------------------------- ---------- ---------- ---------- ---------- ---------- ----
Apache Tomcat/6.
--------------------------
type Status report
message /Chapt2/Chapt2jsp
description The requested resource (/Chapt2/Chapt2jsp) is not available.
--------------------------
Apache Tomcat/6.
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
Are you using any IDE?
how you are deploying ear to server?
how you are deploying ear to server?
Step 2: Create a java web project in you eclipse.So you will have structure something like below
JspProject
|_ JavaSource - Create java classes for ur web application
|_ Webcontent
|_ WEB-INF - place ur web.xml
|_ Chapt2
|_ Chapt2.jsp
So now ur ready with the project structure, which u can deploy in tomcat.
Your web.xml should have this entry to access ur Chapt2.jsp by default.
<welcome-file-list>
<welcome-file>Chapt2/Chapt
</welcome-file-list>
Step 3: Place your project folder to Tomcat/webapps/(JspProject
Step 4: Start tomcat and type the url in browser http://localhost:8080/JspProject/
You should see the Chapt2.jsp content displayed.
Note: Include the Servlet.jar and other required jars as required in ur eclipse.
-Murali*