I have created a jsp file which will give an output in JSON format using java class and servlet, i am new to java and i don't have idea about the deployment of jsp file. Can anyone suggest me how to do it? I used to develop an asp.net web application in which there was a specific option available which called " publish project", but i cant find in eclipse.
I already have a php server in which i have uploaded few php files, can i use the same server to upload this file?
Currently, my application is running fine on localhost.
Please help me with this matter and thank you for your time.
To publish your project in Eclipse:
Right click your project
Export
Under Web > Choose WAR
Then just follow the instructions and your good to go.
It is done as a component of a WAR (Web Application Archive) file.
Upon deployment, JSP files are processed by the Servlet container. The processing effectively turns them into Servlets, such that the plain text of the JSP becomes println statements in the response of the Servlet, and the embedded Java code in the JSP becomes regular Java code in the Servlet.
The packaging details are covered in detail in the JEE7 tutorial, although earlier tutorials don't differ much in the details.
i assume you are using tomcat in your php? you can use tomcat or glassfish server to deploy your application. you just need the .war file of your application and upload it to the admin page of tomcat or glassfish server.
It should be in .war file format
Here are few links which can help you in building it from eclipse, link1, link2.
For deployment, there should be a server -- tomcat / glassfish / jboss which can provide platform to execute .war files.
IDEs and .war files are great productivity tools, but I'm of a mind that you need to understand how these things work from the command line. I'm using Apache Tomcat running on a Raspberry Pi as a development server. I developed my .jsp and then just copied to where it needed to be. In this example login.jsp needs to be in the root folder of an app called SEM. So, just copy it there and access it via its URL.
sudo cp login.jsp $CATALINA_BASE/webapps/SEM
http://localhost:8080/SEM/login.jsp
Didn't even have to restart Tomcat. :)
Related
I want to convert my Swing application to web application. Getting help from How to deploy swing application on web browser?
Please have a look to second step of first answer ("Install this [AjaxSwing] application in your system"). Where can I upload jar file and how?
You don't actually upload a jar file, I think the related answer is misleading. Webswing is a software you download and install on-premise. It starts a web server which serves your application on a web page. All you need to do is create a configuration where you specify the path to your jar file. As Gilbert pointed out, you can get the idea when you read the Webswing documentation https://www.webswing.org/docs/20.1/start/quickstart.html
i have just created a web project that contains a bunch of jsp and html pages.i need to know how to Deploy them(or provide access) to client computers using a single server(intranet) and where do i need to install JRE because jsp have java code and sql queries in them which interacts with mysql database.
You just have to install a J2EE container into your intranet and deploy your war file on it.
You can easily do this for example using Apache Tomcat, but there is a lot of other products, free or not, on the market.
Quite simple ! Create its war file using any build tools like maven or ant and deploy it on tomcat server and start your server.
I have made an app using Tomcat as my server. It uses JSP pages and java servlets.
If I copy my webapp (the folder) to some other server, will it run? What are the requirements for it to work/not work?
EDIT: Thanks for the answers. One more thing, what if some of my code uses filepath, that originates from the bin folder of Tomcat. For eg: "../webapps/MyApp/WEB-INF/sample.txt"
Is the directory structure the same in all servers?
Java servlets and JSP are intended to be portable technologies. There is a servlet standard and a JSP standard. Any servlet container (such as Tomcat) that implements the version of the standard that your code uses should be able to run your code.
You should move your web application around by copying its web application archive (WAR) file, rather thsn the directory (the extracted content of the WAR).
Ofcourse it will run , there are many servers out there that support jsp/servlet . Most of them are free for development and some are paid for deployment. See this link for more info
For most of the containers (i am not sure for all but most of them) like Tomcat, Jetty, Resin etc, you don't need to modify the project. You can place your project war file in the webapps directory and the project will get deployed on starting the server.
I have installed Java and developed on my laptop. Now I want to access those files from my PC using HTTP. Both machines are on the same network. I'd like to access the page as we do in PHP:
http:// and the path
How can I do it? I can see the files using this url: file://machine-name/login.html, but it's not opening in HTTP, replacing file from the url. Please help
Unlike PHP, in Java you can serve only JSP or Servlets. You will need to have an Application Server - like Tomcat, to deploy your web components. There are many different ways how you can package your web components. Typically all files (JSP, Servlets, Classes) etc. are packaged in a 'war' file. Thiw war file can be deployed to any Java compliant application servers.
Try this URL - Simple Tomcat application
Hope this helps.
Regards,
Sreehari.
I am q java web apps developer.
I am using Eclipse+Tomcat.
Currently I am working on about 10 web apps.
Here is my problem:
My web apps are not all placed under a single folder, they are located in different places.
To test my changes I have to export my web apps into war files or to move the updated files manually every time so the Tomcat will recognize them.
This seems like a waste of time for me.
Is there a way to tell tomcat where my web apps located instead of copying files every time?
Are you using Eclipse Webtools?
If you're not, consider doing so. You will be able to configure Eclipse to launch Tomcat with your web applications, have them auto-reloaded, etc...
Short of that, you could still configure your Tomcat server to pick up your web applications from wherever you want by specifying appropriate document base in either server.xml or your webapp's context.xml
Here's a link to Server Tools documentation
Here comes a tutorial telling you how tomcat and eclipse are supposed to work together to forge a development environment.
http://www.ibm.com/developerworks/opensource/library/os-eclipse-tomcat/index.html
Follow it and you will not be exporting the .war all the time.
You can do this easily with Tomcat. For each app you want run from somewhere else, you need to place a context fragment in $CATALINA_HOME/conf/Catalina/[host] directory. For example,
app1.xml:
<?xml version="1.0" encoding="UTF-8"?>
<Context docBase="/anywhere/app1" swallowOutput="true">
</Context>
The xml file name will be your context name.
You don't actually have to use Tomcat to test your apps... You can use the Jetty web server from within Eclipse, which is very comfortable.
You can try using Ant or Maven. It will solve this problems
I think you should load your application from context files rather than the server.xml. There is no need to load a application every time in the container. You can run your application from the place where it is.
Please use this link