I have the following folder structure in my project.
> src/
>>main/
>>>webapp/
>>>>WEB_INF/
>>>>>pages/
>>>>>>js/
All my script files are located in js folder and my jsp page is located in pages folder.In order to include abc.js script in my jsp page I wrote the following line
<script type="text/javascript" src="/WEB-INF/pages/js/abc.js"></script>
But I got following error
"NetworkError: 404 Not Found - http://localhost:8080/WEB-INF/pages/js/abc.js"
I am using jetty server to deploy my project. For running it I am using
mvn jetty:run
If I am putting my script file directly in webapp folder and including script in following way then it is working perfectly fine.
<script type="text/javascript" src="abc.js"></script>
But I want to maintain folder structure of my project by putting all scripts in js folder.
Can somebody please tell me why jetty server is taking files located only in webapp folder?
I am using windows7
Your src is incorrect. Java Servlet specifications states explicitly that no document under WEB-INF directory will be available to the webserver. You need to place your JavaScript file outside of it.
Usually, you place jsp files inside of it, because they're not accessed directly. They're accessed through a Servlet or any other web development framework in Java.
If you want to maintain your folder structure, just put your js folder on the web archive root:
webapp/
js
WEB-INF/
classes/
lib/
pages/
web-xml
WEB-INF directory was designed exactly to prevent that users could access files they should not get access to, such as classes, lib directories, or web.xml deployment descriptor.
Related
I read some similar issue on Stack Overflow but still stuck with this problem. The web Django can deploy on IIS well except CSS style for admin and all CSS.
What I tried:
Use whitenoise -> I got error when I wrote whitenoise tag in middleware. then I stopped use this way
Use add virtual directory
more information -> I created virtual enviroment
venv_>my django>app folder
honestly, I really don't know where virtual directory (named static) should be, then I tried at
default web site
venv_
my project folder (my static folder after use collectstatic Django)
I tried to use path physical to (my static folder after use collectstatic Django)
it still not working
More information:
I used findstatic but got another path not (collectstatic path in my project app)
it is in my venv_ package?
I am using Oracle's ORDS 20.2 which has jetty/9.4.28.v20200408 embedded, APEX 20.1, Database 18c XE, Google Chrome Version 84.0.4147.135 (Official Build) (64-bit), opera Version:70.0.3728.106
and Windows 7 Ultimate.
In APEX there is a directory that has APEX's static files - CSS and Javascript files and image files. I need to enable gzip for that directory and tell the browser to cache it for at least 12 hours in order to improve performance for APEX development environment and my APEX applications according to Oracle's documentation here, https://docs.oracle.com/en/database/oracle/application-express/19.2/htmig/performance-optimization-tasks.html#GUID-668ED330-AFDC-4A43-AA11-D67FCCA58DA1
I've created a folder named "etc" under the "standalone" folder of my ORDS configuration directory. That's the folder where I should put any Jetty's Xml configuration files. Then created a file called "jetty.xml" with the following contents to implement what is in the Jetty's documentation about sending Cache-Control header,
https://www.eclipse.org/jetty/documentation/current/header-filter.html And
<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN"
"http://www.eclipse.org/jetty/configure.dtd">
<filter>
<filter-name>HeaderFilter</filter-name>
<filter-class>org.eclipse.jetty.servlets.HeaderFilter</filter-class>
<init-param>
<param-name>headerConfig</param-name>
<param-value>
"add Cache-Control: max-age=43200"
</param-value>
<init-param>
<param-name>includedPaths</param-name>
<param-value>
"D:\ords\images"
</param-value>
</init-param>
</filter>
But when I run ORDS through a batch file which has
cd D:\Original\Oracle_ORDS_Editions\ords-20.2.0.178.1804
d:
java -jar ords.war standalone
the cmd window opens then vanishes automatically.
I need to know why the code fails and still need to enable gzip for that directory. Thank you.
The HeaderFilter is for use with webapps that are traditionally deployed via a webapp archive (WAR file).
The documented configuration for HeaderFilter is for the war internal WEB-INF/web.xml servlet descriptor that is specific to the webapp being deployed (typically found within a WAR file).
Arbitrarily creating etc directories and jetty.xml files are never a relevant form of configuration for Jetty.
The etc directory and the jetty.xml concepts are only relevant if you are using the standalone Jetty techniques (such as what's seen in jetty-home or the older jetty-distribution archives). More specifically, the start.jar within the jetty-home archive is the only one that looks for and uses either the etc directory or the jetty.xml file.
The jetty.xml, that the start.jar is aware, of is never managed by manually creating it or editing it. In fact it's a typically a read-only file that comes with the jetty-home archive, and is used in-place. The etc directory is found within the jetty-home archive, and can also be seen in the application specific configuration of Jetty standalone known as the ${jetty.base} directory.
You mentioned "jetty/9.4.28.v20200408 embedded" which typically means it's not using the standalone Jetty concepts. In an embedded Jetty scenario, the configuration of the Jetty server is typically done within the configuration techniques of the parent project (Oracle ORDS in your case). You'll need to know how that Jetty server is configured, and work within the limits of whatever configuration that parent project provides to you.
I have successfully installed Glassfish on a Ubuntu 16.04 instance.
The deployment of my webservice is also succesfull, When I launch the application, I get a page that says
Web Application Links
If the server or listener is not running, the link may not work. In this event, check the status of the server instance. After launching the web application, use the browser's back button to return to this screen.
When I click on a link (both HTTP and HTTPS), I get a 404 error.
I presume that there must be something wrong with my server, but all tutorials about setting up a glassfish server seem to go straight out-of-the-box, so I don't get a clue why it isn't working in my case.
I also can't find where to check the listeners or server instance, and what they should be configured like.
Last thing to mention: I have never used glassfish before, I only need to test if a webservice is working like expected before sending it to a customer who will deploy it himself.
What directory structure do you use in your *.war file? By default static files (like index.html) should be placed in the root folder - not in the WEB-INF. So a typical directory structure would look like this:
myWebApp/
WEB-INF/
web.xml
lib/
MyLib.jar
classes/
mypackage/
MyServlet.class
index.html
index.jsp
I deploy a Web Service using REST and I have the same problem.
My structure is :
MyProject
.idea
lib
out
src
MyApp
Helloworld
web
web.xml
WEB-INF
index.jsp
MyProject.iml
External Librairies
I followed a tuto (https://www.jetbrains.com/help/idea/2017.1/creating-and-running-your-first-restful-web-service-on-glassfish-application-server.html#d76541e113) and I should have a web page on http://localhost:port/appArtefact/helloworld
I've been working on an ember app and I'm trying to create a production build so my manager can look at it, I ran
ember build --environment=production
but it when I open the index.html file I get a 404 error for my app.css and app.js files, this only happens when the files are not served by an HTTP server. Is it possible to run the files locally?
Not really, when using the file URI scheme file://path/to/your/app the relative paths used in index.html won't be resolved properly. It will also break the router even if you correct the paths manually.
Just want to ask about my problem. I am trying to setup a jetty server and included my own webapp. I put the web application in the webapp folder of jetty server. I also included the necessary libraries needed by the web application in lib/ext folder of jetty, it is not included in the war file. when i run the jetty server and access the webapp, i get the 'NoClassDefFoundError'.
I run the jetty server using the 'java -jar start.jar'. I am also sure that the jar file which contains the class that causes the error is in the classpath.
Did i miss something?
Thank you.