Create and publish a static web project in Eclipse - eclipse

when I tried to create and publish a static web project in eclipse I got: "Error copying file index.html: No such file or directory"
My environment: SuSE 12.2, Eclipse Indigo Release 2, Apache2 2.2.22,
This is what I did to create the project:
1) Create new Server
Basic, HTTP Server
Publishing Directory: /srv/www/htdocs
Enable publishing to this server: true
2) Create Project
New -> Static Web Project
Project Name: Simplepage
Target Runtime: HTTP Server (from 1)
Default Configuration
Content root: Simplepage
Web content folder name: WebContent
3) Create very simple page
Create new HTML file
Parent folder: Simplepage/WebContent
Name: index.html
Content:<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=${encoding}">
<title>Insert title here</title>
</head>
<body>
Test
</body>
</html>
4) Start Project
Right Click on Project Name -> Run as -> Run on Server
Here I got the error message mentioned above.
At this point there is a new folder /srv/www/htdocs/Simplepage created but has no content.
Later I made a test with the following configuration:
Change publishing directory to: "/srv/www/htdocs/XY"
Start Project gives error: "Access forbidden! You don't have permission to access the requested directory..."
At this time there is a new directory created: /srv/www/htdocs/XY/Simplepage containing the file index.html.
The window in eclipse is showing the path http://localhost/Simplepage/. When I change this manually to http://localhost/XY/Simplepage/ the newly created page is shown.
I don't understand this behaviour. Can someone explain this?

You have installed Apache2 server on your home computer, with the publishing directory /srv/www
Note that Apache2 runs on its own user (on my Ubuntu it is www-data). Apache's publishing directory /srv/www is normally owned by Apache's user.
You have also directed HTTP Server of Eclipse to the same directory. Note that this server is different from Apache; it is run by Eclipse inside its belly, and usually on different ports from Apache, to avoid port conflict. I think this server is run on the same user Eclipse runs, i.e., your regular user on your home comp.
I think that the error messages you get, are permission mismatch: Eclipse cannot publish in directories owned by Apache's user.
The solution is not to try to use Apache's directories but rather the default directories of Eclipse.
I have explained this in more detail here: Eclipse Web (http) servers: Debugging and publishing http files in Eclipse.
I do use both Eclipse' HTTP Preview server and Apache2:
Eclipse' HTTP Preview server for files I work on in Eclipse, and
Apache2 to run a localhost copy of my Wordpress site.
When files I work on in Eclipse, are mature, I transfer them manually to Wordpress as posts or pages.

Related

Using index.html for Hugo file serving

I am able to serve a Hugo web site on port 1313. I don't have access to port 80, but I can write index.html and the public_html directory. How do I configure Hugo so that my site is served from mydomain.com instead of mydomain.com:1313?
You don't need to run as a server. Build the site by just running command "HUGO". This will generate a public or output folder. Copy the contents of the public folder and past to the publich_html directory of your hosting. This will work like normal HTML pages.
For the development purpose only we need to use as "HUGO SERVER"

The origin server did not find a current representation for the target resource or is not ... error when running jsp page

I am trying to run this code in my Eclipse JSP dynamic web page. But on running it in the Tomcat Server Version 9.0, I am getting an error 404 message. Error Message-The origin server did not find a current representation for the target resource or is not willing to disclose that one exists. I was trying to include a header page in my other jsp page in this code.
So far I have tried switching the location of the server via server properties. I have also checked the Use Tomcat installation checkbox in Server Locations. Still, I am getting this error.
<!DOCTYPE html>
<html>
<head>
<title>Insert title here</title>
</head>
<body>
<jsp:forward page="http://localhost:8080/HelloJSP/HeaderPage.jsp" />
</body>
</html>
If the page is under WEB-INF folder, an 404 error message might appear. I had the similar problem.
I put the pages under the WebContent folder instead. In Eclipse, the location of files may look confusing. Sometimes right click the file and look at their properties for paths. Just like below :
As you can see, even though pages look like they are under WEB-INF, they are under WebContent. Then, you won't see 404. And you can put the url to see your page in your browser.
If this doesn't help, then check your Web Project Settings.
Right-click your project, go to Properties, and find Web Project Settings.
Can you see my Context root "/" ? If I want to run my jquery.html page, I just type
localhost:8080/jquery.html
If you change your context root to "test", then you type :
localhost:8080/test/jquery.html
Don't forget to clean your Tomcat after changing your context root. Otherwise, it won't apply changes.
Thank You for your help :)
Actually, this problem was solved once I removed all the server from eclipse and switched it off. Then I readded the sever once again and it started working. Still not able to find the reason this error was caused but it was fixed by using the above method.

Deploy Jekyll project without a webserver

I created a blog with Jekyll and now I need to deploy it and send it to a person that need to navigate it without a web server. So, I entered jekyll build from terminal and get the compiled project in _site. But now, if I open index.html it doesn't get the assets (CSS). In the head tag tag there's /css/main.css while I need css/main.css (no initial slash). I don't want to change manually the url, so I'm asking if there's a way to deploy a Jakyll project for showing in local without webserver.
This is possible only if you know where, in the file system, it will be deployed.
Examples :
Linux
For a deployment in /home/user/www, go in _config.yml and set baseurl: /home/user/www
Windows
For a deployment in C:/Users/Toto/www, go in _config.yml and set baseurl: /C:/Users/Toto/www
Deployment means copying generated files in the target folder, not copying the _site folder.
Do a jekyll build and send you files with deploy instructions.
Edit:
This answer is for you, not the client.
As you client is certainly running windows, you just set your baseurl: /C:/_site, zip the _site folder and ask the client to unzip in C:/.
The client will just have to click on C:/_site/index.html to start the site in his default browser.
Change the assets directory to relative paths such as: assets/css/.
This will work on a server or locally.
Set a page variable to represent the nesting in your Yaml front matter. Then, append that variable to your assets.
---
layout: default
title: Nested Page
path: ../
---
or
---
layout: default
title: Root level page
path: ""
---
<link rel="stylesheet" href="{{ page.path }}assets/stylesheets/style.css">

crossdomain.xml location when Tomcat is running in Eclipse

I need to use a crossdomain.xml file to access my WebApp from a dev sandbox.
I gather from other SO posts that it should be accessible at http://localhost:8080/crossdomain.xml , hence in tomcat ROOT webapp.
Where the heck is that ROOT directory when running Tomcat in Eclipse?
Edit: Tomcat is using a Runtime Environment named "Apache Tomcat v6.0" which is using a "Tomcat installation directory" set to "D:\dev\apache-tomcat-6.0.33"
I tried to drop crossdomain.xml in "D:\dev\apache-tomcat-6.0.33\webapps\ROOT" but I still get a 404 trying to access http://localhost:8080/crossdomain.xml from a browser. In fact, anything in that ROOT directory is accessible.
Edit 2: In the server launch configuration, there is an "Arguments" tab listing the following -Dcatalina.base="D:\dev\workspaces\project\.metadata\.plugins\org.eclipse.wst.server.core\tmp1" -Dcatalina.home="D:\dev\apache-tomcat-6.0.33" -Dwtp.deploy="D:\dev\workspaces\project\.metadata\.plugins\org.eclipse.wst.server.core\tmp1\wtpwebapps" -Djava.endorsed.dirs="D:\dev\apache-tomcat-6.0.33\endorsed"
Hence, I pasted the crossdomain.xml into D:\dev\workspaces\project\.metadata\.plugins\org.eclipse.wst.server.core\tmp1\wtpwebapps\ROOT and ... it worked. Seriously.
Thanks in advance
As per edit #2
In server launch configuration, there is an "Arguments" tab listing the following VM Arguments
-Dcatalina.base="D:\dev\workspaces\project\.metadata\.plugins\org.eclipse.wst.server.core\tmp1" -Dcatalina.home="D:\dev\apache-tomcat-6.0.33" -Dwtp.deploy="D:\dev\workspaces\project\.metadata\.plugins\org.eclipse.wst.server.core\tmp1\wtpwebapps" -Djava.endorsed.dirs="D:\dev\apache-tomcat-6.0.33\endorsed"
Hence, I pasted the crossdomain.xml into D:\dev\workspaces\project\.metadata\.plugins\org.eclipse.wst.server.core\tmp1\wtpwebapps\ROOT

Zend server deployment

I'm deploying sample Zend apps on Zend server, following official tutorials. No matter what I deploy the only thing that I can access is the hello world page (Hello world
says hello).
How can I access real application?
host/address/public and host/address/index.php or other permutations don't work...
When you create your zpk file with Zend Studio there is a deployment.xml file that specifies some vhost settings as well as various other dependencies and triggers.
If you double click this file within Zend Studio you will be presented with a gui that helps you create this file.
The two fields of importance to this question are "Application directory" and "Document Root". If you have a Zend Framework application the most likely settings for this are:
Application Directory: data
Document Root (main public directory): data/public
The document root is the most important part as it defines the directory where apache executes the first file.
You then export the project into a zpk and upload that within Zend Server.
Once uploaded you will be presented with a "Set Installation Details" screen. There you will define the virtual host directory name.
For a simple deployment to your localhost or your server IP you can have the following:
Display Name: Address App
Virtual Host: Default
Path: address
This will then deploy your application to: http://localhost/address or http://192.168.0.*/address
You can also deploy it with a url eg:
Display Name: Address App
Virtual Host: click "add new" then enter the url eg. myaddressapp.com
Path: leave blank
This will then deploy your application to: http://myaddressapp.com. IF you are not deploying to a live site you can fake the url by entering a record in your hosts file
Alternatively, I started writing a blog post a while ago on how to deploy to Zend Server in a VM. This does everything automatically so you dont have to rely on exporting and importing. Here is the work in progress of the post: https://docs.google.com/document/pub?id=1bR58tXWpkezomGiv9cnkySrXxKItoEUQ6E6V9a8n46A