Loading failed JavaScript file when deploy web application on weblogic - javascript

I have a problem with loading a JavaScript file on a jsp page when I deploy my web application on a weblogic server. Before I deployed it on Tomcat 7 and it worked normally.
First I see on console window of Firefox. My jsp page couldn't load js file on /resources/ folder (this folder is the same level with /WEB-INF/):
Loading failed for the <script> with source “http ://10.3.11.25:7001/resources/assets/global/plugins/jquery.min.js”. 10.3.11.25:7001:104
Image I have capture:
I tried copying the url: http ://10.3.11.25:7001/resources/assets/global/plugins/jquery.min.js to the address bar.
I can access it, but I only can download the js file (It not display the source code on browser as normally).
What is my problem? I deploy my web application on weblogic 12c.
UPDATE:
Network tab load js file ok, all status is 200:
Source code include on jsp:
<script src="resources/assets/global/plugins/jquery.min.js"
type="text/javascript"></script>
<script src="resources/assets/global/plugins/jquery-migrate.min.js"
type="text/javascript"></script>
UPDATE 2:
All status is 200 but load O KB and response is notthing
When I copy the js url to address bar it show popup download it (not display the source code as normally)

I have resolve my problem. My web application can't read the js file beacause have problem with MIME type on weblogic.
I add following mime mapping to web.xml and problem has been resolved:
<mime-mapping>
<extension>xml</extension>
<mime-type>text/xml</mime-type>
</mime-mapping>
<mime-mapping>
<extension>js</extension>
<mime-type>text/javascript</mime-type>
</mime-mapping>

Related

Forwarded file URL not loading and displaying file in the correct location

I am hosting a web server using Express JS, and have middleware set up so that all requests to *.mydomain.com/cdn/* get forwarded to cdn.mydomain.com. In my html file I have the following lines:
<style>
#import url("/cdn/style.css");
</style>
<script src="/cdn/script.js"></script>
However, when looking at Developer Tools > Sources on the site, it shows the css file as cdn.mydomain.com/style.css but the javascript file as mydomain.com/cdn/script.js.
When looking at the network tab, the request gets properly forwarded then loaded, with the final Request URL header showing https://cdn.mydomain.com/script.js.
Is this performance expected of javascript files or is something playing up? Thanks in advance for any advice you're able to offer.

Failed to load resource: the server responded with a status of 409

After an automatic WordPress update the plugin forms (Contact Form 7) now display a slash just below them and are no longer firing the wpcf7mailsent listener event, so it is no longer being redirected to the thanks page after submitting the form.
This error: “the server responded with a status of 409 or also known as net :: ERR_ABORTED 409” from what I see is a problem loading styles.css and scripts.js files.
This must be the reason why it is not issuing the wpcf7mailsent listener event and a slash just below the forms.
Strangely if on the same page I manually click and open the styles.css file via URL, the file starts to load on the page and it stops showing that bar just below the form.
For this reason I am saying that you are not loading the styles.css and scripts.js files, as they do not even appear in the uploaded files folder, just after I open them by URL.
Here’s the test I did to show it:
The error happening:
https://ibb.co/Vvm8jwG
Did not load CSS file and JS file:
https://ibb.co/kHszgW9
After I open the CSS style link that says it didn’t load:
https://ibb.co/FXcLRXQ
https://ibb.co/997nMgK
You no longer see the error that you did not upload the CSS file and now the file has been uploaded to the folder showing the contents. The same will happen with the JS file if I manually load it as the CSS file.
https://ibb.co/jGPQ2MH
https://ibb.co/chVjRTQ
What I already tried to do to fix, but it didn’t work:
– I disabled several plugins
– I updated the plugin
– I reinstalled the plugin
– I tested in other browsers, the error persists
Other sites with Contact Form 7 are also experiencing the same.
Environment Settings:
Theme: Javelin
WordPress: 5.2.4
PHP: 7.1.24
Hosting: Hostgator
The page I need help with: https://verdecia.com.br/central-de-atendimento/
For anyone who is facing this issue, this is a known issue in bluehost and hostgator hosting. Basically the root reason for this seems to be that they are blocking image/js/css or other assets in any path with contact string.
The reason that contact form 7 assets are randomly blocked is probably also due to this same reason.
I had html websites running on my server where contact (or any other) page with assets in for example /images/contact/ folder also did not load with 409 conflict error, due to the contact path in the assets folder.
Unfortunately I found no solution to this just like many many users out there. Check out these links:
Link 1
Link 2
What is the solution?
Well wasting time with hosting provider support is of no use. I just use
hostgator/bluehost for development purpose. There are many hosting providers out there,
so next time you can choose some other one, especially for live websites.
For custom websites, avoid naming your assets folder to anything that has contact in it.
For CF7 in wordpress stop loading the assets in wp-config file using define( 'WPCF7_LOAD_JS', false ); define( 'WPCF7_LOAD_CSS', false ); and manually load the files in the header by separately downloading the files and importing them.
EDIT:
I have been using a simpler fix recently when using CF7, just rename the plugin folder from contact-form-7 to anything without contact keyword, like cf7. This will start loading all assets without the conflict.

Javascript in different folder than HTML

I'm new to web development. I have issues with having files stored in different folders (for safety reasons). Here's the index page which returns an error
<head>
<script src="../scripts/script.js"></script>
</head>
<body>
<?php include "../php/page.php"; ?>
Other code here...
</body>
My file structure is as follows
www/
html/
index.php
scripts/
script.js
php/
page.php
I don't get why including php file works (row 5 in the example code provided) and including javascript doesn't (row 2). I guess you're interested about the error so here's what Google Chrome's console says
Failed to load resource: the server responded with a status of 404 (Not Found)
It also shows that link to the resource and it appears to look for my.server.address/scripts/script.js like it doesn't care the ../ part. Can someone explain this behaviour?
PHP resolves paths on the computer's file system.
Web browsers resolve paths on the URL.
Your HTTP server has http://my.server.address/ mapping to www/html on the file system.
So ../scripts/script.js goes up one level from / … to / (because that is the top), then down to /scripts then down to /scripts/script.js.
The browser asks the HTTP server for /scripts/script.js and it maps that to the file system — www/html/scripts/script.js and returns a 404 because that file doesn't exist there.
The browser can only read data that the web server will send to it, and by keeping the scripts directory outside of the document root you haven't make it available via the web server.
Change
<script src="../scripts/script.js"></script>
to
<script src="/scripts/script.js"></script>
And your folder structure should be:
www/html/index.php
www/html/scripts/script.js
www/html/php/page.php

Failed to load resource from gstatic.com/charts

I use gstatic.com/charts to load graph to the web page.
But several days ago the webpage gave error
GET https://www.gstatic.com/charts/current/css/util/util.css
In network tab it shows that util.css is not loaded.
Checked via Incognito- the same problem.
Any ideas?
The problem was:
The JS is connected via 'https://www.gstatic.com/charts/loader.js'. From the JS file the CSS files are uploaded via the URL, written in that JS file.
I downloaded that JS file to include it locally, however they changed the URL of css file and this problem occured.
For me it helped to include the JS file via the above URL.

ExpressJS - Blocked by client - Unable to load js file?

I have loaded my express app on a server (I used heroku). When I test my app locally it works fine but when I load the page on the web it gives me a net::ERR_BLOCKED_BY_CLIENT saying that it is not able to load a JS file that I define in the HTML page:
<script src="./index.js"></script>
If I try to go to: http://<my-page>/index.js it is able to load the file successfully.
Why this doesn't work?
(If you need more information tell me what I need to add)
I finally solved my problem. There was a problem with the Avira Chrome extension that was blocking the file from loading. I simply added my page to the whitelist and it started working as supposed.

Categories