I installed Apache Tomcat on my Windows machine, and it seems like its installed successfuly. I can see the property window, and I can start the server but I don't know what to do next.
Where do I save jsp files at.. do I create a directory or does apache tomcat create its own directories?
that's my only problem.. how do i make and edit files now that its installed
Create the JSP code that you'd like to write in your favorite text editor.
Select "File" and "Save As" from the text editor toolbar. A dialog box appears.
Navigate to the "File name" text field and type the desired file name within quotes. Add a JSP extension to the file name -- for example, "filename.jsp" -- and click "Save."
Put it at location C:\apache-tomcat-7.0.28\webapps\ROOT.
Go to tour browser and enter url "http:// localhost:8080//filename.jsp"
This post will give you description about how you can run your project using Apache Tomcat Server.
I would like to define these terms before proceeding:
Apache Tomcat Server(Jakarta Tomcat): It is an open source web server and servlet container developed by the Apache Software Foundation (ASF). It implements the Java Servlet and the JavaServer Pages (JSP) specifications and provides a pure Java HTTP web server environment for java code to run.
JavaServerPages(JSP): It is a technology that helps in creating dynamically generated web pages.
Step1
Install Java.
Step2
Install Apache Tomcat
At the time of installation, it will by-default recognize JRE path.
(under installed java location directory)
Step3
Now Go-To:
Start
Programs
APACHE TOMCAT
MONITOR TOMCAT
Step4
An icon will appear on the taskbar, this icon will automatically appear after following
above step:
Step5
Click on that icon and START TOMCAT, you can see the following dialog box:
Step6
Now open Mozilla Firefox(or any other browser)
Step7
Type
[http://localhost:8080/][1] on address bar and press enter.
The same can be seen here:
Step8
It will show tomcat, as shown in above window.
(if not, then try again, may be a problem in installation or you’re not following above
steps correctly
Step9
Now, go to:
C:drive
Programs Files
Apache Software Foundation
tomcat
web-apps
(or navigate where you have installed APACHE TOMCAT)
Step10
Open web-apps and “copy your project” or “make new folder”, which you want to run in JSP.
Example: amit2012PROJECT
Now, go back :
Tomcat
Root
Copy Web-inf from root
Paste this “web-inf” in your project folder i.e. amit2012PROJECT
Step11
Create a text file and name it as first.jsp, use the code shown below:
<html>
<head>
<title>blog post:ApacheTomcatServer</title>
</head>
<body>
<%-- START --%>
<%
out.println("UserName = amit2012, ");
out.println("Running first program in JSP.");
%>
<%-- END --%>
</body>
</html>
It includes HTML tags and encloses a JSP scriptlet which is a fragment of Java code that is run when the user requests the page.
Step12
Now for running your folder [ Eg. amit2012PROJECT as shown above]
[http://localhost:8080/][2]foldername.extension in any WebBrowser i.e:
[http://localhost:8080/amit2012PROJECT/first.jsp][3]
The Project will run successfully
Now, you can successfully try running JSP with ApacheTomcatServer.
Folder structure:
Apache-home/webapps/project_name/WEB-INF/classes
all jsp filse should come under project_name folder. and java classes comes under clasess.
Also need to put a special file named web.xml in WEB-INF folder.
You need to read this first. The file and directory structure of a web app.
First you need to start your server by going to bin folder present in tomcat
then double click the start.bat
now the server is up and running
now open a browser ,open tomcat
u will see the homepage of server
i think u might have already created a folder in webapps folder of tomcat
directory structure would look like this tomcatfolder --> webapps --> your file name let it be some " test " --> then the jsp file you have created
to run a jsp file located as shown in the above directory structure u need to type the url localhost:8080/test/file name of jsp
if it runs ok or otherwise if
server throws an error then it needs tools.jar file
go to the directory where u have ur jdk kit
open jdk file, then open lib file
copy tools.jar present in it
now again go to tomcat folder ,
open it and then go to lib folder paste it down there
over,go to browser type the url
$locallhost:8080/test/file name of jsp( dont type the $ symbol)
it should run now now..........
Related
I have made a website using Tomcat Server on Eclipse Mars 2.0 IDE. When I run it on server, I have to manually add the name of the first (home) page of the website i.e the JSP/HTML file.
I want the website to open directly on the server so tell me how to do that please.
If you put an index.html into src/main/resources/static/ and reload the server does it show the content of the index page? If you have no static folder then go ahead and create one :)
In general you have to decide for a context-root which is basically the name of the application. If the name of the application is 'myapp' and the context-root is set to 'myapp' too then you should be able to see the website at serverip:port/myapp/.
If your project is configured as a WebProject you should be able to see Web Project Settings in the properties of the project itself. There you can adjust the context root. If you leave it empty it means that your application will be reachable at serverip:port/.
you can change your welcome-file-list in web.xml
you can refer this
https://cloud.google.com/appengine/docs/flexible/java/configuring-the-web-xml-deployment-descriptor
or look for Configuring the web.xml deployment descriptor
when we directly upload JSP page into tomcat where application deployed directory then why we don't need to restart Tomcat? how tomcat know that it has new JSP page?
when user hit the url /myapp/mynewjsp.jsp He/She always get new jsp deployed page.
Tomcat has an auto deploy feature. When you update JSP files it detects you have done so, compiles it, and replaces the old compiled JSP page with the new one that it compiles into a java class.
http://tomcat.apache.org/tomcat-6.0-doc/deployer-howto.html
If you don't want that to happen, you can turn off the auto deploy feature for your web application. It is described in the link how you do that.
Hey you can use jetty plugin for auto deploying tomcat folder . You don't need to paste your file on webapps folder. If you using maven project structure then add jetty plugin on pom.xml file . There is some command to run like mvn jetty:run etc... May these solution get you out from these problem
I am coding a website using java servlets and am using eclipse and tomcat. When I test it using localhost, it works fine. But when I am deploying it on my actual website, the directory structure is messed up and the files are not called properly.
My eclipse directory structure on localhost is
Project Name
.src/packageName/java files
.WebContent/HTML files.
When I make a call from the html files, I use the relative location and tomcat automatically knows to look in the src/packageName folder. For example, from the /WebContent/login.html page makes a onClick call as follows,
. This will automatically trigger the java file in /src/packageName/welcome
When I am deploying it in my actual website, the WebContent/login.html is throwing an error WebContent/welcome file is not found. How do I tell my website to search in /src/packageName folder?
Hmm...have you been sure to package the application as a war for deployment.
I'm using NetBeans 7.2 and GlassFish 3.1.2 and I'm running a web application with JSPs and Servlets. There seems to be some errors in the output because I'm getting a blank webpage when the app is run. I understand that the log file is located in glassfish/domains/logs folder, but I'm not able to see any System.out or System.err inside of that text file.
Is there anything I have to configure so that I can read the log and come to know as to where I'm going wrong? Ideally I'm trying to debug the servlet.
In NetBeans, go to Tools->Servers. Select the GlassFish Server and on the 'common' tab the 'Domains folder' + the 'Domain Name' is the root folder you need to browse to on your machine. Inside of that folder, you'll see a 'logs' folder which will contain the 'server.log' file.
I'm using Eclipse Java EE IDE and launch Tomcat from the Server's tab on Eclipse.
Where does Eclipse store generated servlet .java files for JSP files? I've checked the Tomcat installation directory, but nothing there.
Thanks.
Doubleclick the server entry in Servers view and check the path represented by Server path. Explore in there from inside the workspace directory. The generated classes are there.
If you choose the 2nd option Use Tomcat installation, then it will be available Tomcat's /work folder, there where you expected it to be.
go to your application work space directory(not eclipse installation directory) in windows explorer(not in eclipse IDE explorer).
in my laptop it is d:/applicationdata/j2ee
then follow the path as:
work space directory(in my case j2ee)/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/work/catalina/localhost
here u will find your application
Eclipse doesn't generate servlet files for JSP files. Validation happens directly on JSP syntax. When a JSP is deployed to an app server like Tomcat, the server may choose to generate servlet files to disk, but that is not required. The generation and compilation can happen in memory or the app server may even compile JSP files directly to bytecode.
I don't know specifically about Tomcat, but if it does generate servlet files to disk, the temporary directory containing these files will be somewhere under your Tomcat install.
/home/waheguru/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/work/Catalina/localhost/jspnotes/org/apache/jsp
localhost or your website name,
project name is jspnotes, whatever your project.
This path is shown in Linux Mint.
Check META-INF\context.xml file from your work space. There will be path metioned like below
workDir="C:\apache-tomcat-7.0.39\work"
In above path you will find the package structure of your project and in it there will be both *_jsp.java and *_jsp.class