deploying angular to weblogic - java

I have an angular app that works absolutely fine on Eclipse (Neon) + Tomcat environment.
But when I export the project as a WAR file and deploy it on a Weblogic server (10.3.6) it does not load the app. It doesn't throw any error message as well. It just gives me a blank page on IE without loading any of the contents of the html.
It looks like I am missing some kind of configuration while exporting this to weblogic as a WAR file. How can I fix this?
Sample Code - index.html
<html ng-app="testapp" lang="en">
<head>
<title>New App</title>
<script src="angular.min.js"></script>
<script src="controller.js"></script>
</head>
<body ng-controller="ctrl">
{{var}}
</body>
</html>
controller.js
var app = angular.module('testapp', []);
app.controller('ctrl', function($scope, $http) {
$scope.var = 'wat2do';
});

Related

How to call a jar applet file in html

I have copied a very simple applet (just a written message) in java and created a jar file. I called the jar file with the following code but when I opened the file in a browser nothing's appearing (apart from the header). What beginners mistake am I making?
<html>
<head>
Chess App
</head>
<body>
<applet code="Main.class" archive="JavaChessGradeApplet.jar" width=640 height=480></applet>
</body>
</head>
</html>

HTTP Status 500 - Unable to compile class for JSP Java8, Tomcat8.5

I have a main jsp file which makes use of java class in the boxers package. But when I try to run jsp, the following error occures:
HTTP Status 500 - Unable to compile class for JSP:in the jsp file: /web/date_info.jsp boxers.B cannot be resolved to a type.
date_info.jsp
<%#page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<p><%= boxers.B.voice()%></p>
</body>
</html>
B class:
package boxers;
public class B {
public static String voice()
{
return "HELLO";
}
}
I've read the conflict between versions can cause this; my Java version is 8, Tomcat 8.5..
I've looked into webapps/my_app/build/web/WEB-INF/classes/boxers folder and there is a B.class file...
EDIT: I wonder if those who downvote at least know the answer to the question.
Figured it out. The application wasn't deployed correctly. The deployment process, described here helped me out. In particular - copying web application archive file (.war) and copying unpacked web application directory. My main mistake was that initially I applied the second method in the wrong way - copied all the folders in the app directory, created by Netbeans (build, src, web etc), while only NetbeansProjects/app_name/build/web's content should have been copied into tomcat/app_name/.
Or just copy the war-file of NebeansProjects/app_name/dist/ into tomcat/webapps - the tomcat will create the appropriate folder with the files himself seconds later.
tl;dr: wrong deploment, copypaste war or web's content.

Angular App on Tomcat Server: Unable to find /app.js 404 Error

I have deployed my Angular APP on Tomcat Server by manually copying all the files to /webapps/(mp app) folder .
The index.html does load when I open http://localhost:8080/bar-chart-4/.
But , Tomcat cant find any .js files defined in the index.html, due to Resource Not Found 404 Error and the page is not rendered properly. The screenshot of Errors shown by debugging Page with F12 is shown in image below.
All .js files in index.html have been declared relative to project root folder.
Can someone help me to configure Tomcat to find the files in my Project Folder without making changes to the index.html file?
I had the same issue with an Angular application running under Tomcat. Using Context docBase will affect all apps on the server I think. I found that a better solution was to use base-href during the build step in Angular.
e.g. ng build --base-href /bar-chart-4/
Have a look here for more info which explains it in detail: https://angular.io/guide/deployment
I added this line in my server.xml file .
Context docBase="/bar-chart-4" path=""
And now the app loads fine on opening http://localhost:8080/bar-chart-4/
in your package.json, you could set the base-href when you build the "dist":
{
"name": "projectname",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build --base-href /bar-chart-4/",
... snip...
}
This will prepend "/bar-chart-4/" in front of all your references:
<body>
<app-root></app-root>
<script src="/bar-chart-4/runtime-es2015.js" type="module"></script>
<script src="/bar-chart-4/runtime-es5.js" nomodule defer></script>
<script src="/bar-chart-4/polyfills-es5.js" nomodule defer></script>
<script src="/bar-chart-4/polyfills-es2015.js" type="module"></script>
<script src="/bar-chart-4/styles-es2015.js" type="module"></script>
<script src="/bar-chart-4/styles-es5.js" nomodule defer></script>
<script src="/bar-chart-4/vendor-es2015.js" type="module"></script>
<script src="/bar-chart-4/vendor-es5.js" nomodule defer></script>
<script src="/bar-chart-4/main-es2015.js" type="module"></script>
<script src="/bar-chart-4/main-es5.js" nomodule defer></script>
</body>
NOTE: I, too, had to do this because I'm deploying the client UI (angular) "dist" folder as part of a Spring application WAR file [deployed on tomcat] and we always define a context root (ex: https://myserver.ext/myApp). So I have a gradle bruild script in my application which calls NpmTask "run build" and my package.json defines the context root (ng build --base-href /myapp) as defined above. That way, I can code the UI using the rapid "ng serve" and I can also build the dist and define the context root in the "ng build" for when I deploy a new version to tomcat.

Applet not running in Openbravo

As per my requirement, i want to call applet from servlet/jsp, I followed below steps,
Created Applet java class file and copied in web/jsp
Then called that applet class in jsp file using
But getting ClassNotFoundException, same code running other than openbravo project, working fine.
I am unable to find the root cause. Please help me.
<html>
<head>
<title>Welcome JSP-Applet Page</title>
</head>
<body>
<jsp:plugin type="applet" code="ButtonMoveApplet.class" width="400" height="400">
<jsp:fallback>
<p>Unable to load applet</p>
</jsp:fallback>
</jsp:plugin>
</body>
</html>

how to load CSS file into jsp

I created a jsp page as follows:
<%# page contentType="text/css" %>
<html>
<head>
<title>Login page</title>
<link href="/css/loginstyle.css" rel="stylesheet" type="text/css">
</head>
<body>
<h1> India welfare</h1>
<p> welcome </p>
</body>
</html>
and named it as login.jsp
and i also created a css file called loginstyle.css and the code of the .css file is as follows:
body
{
background-color:#d0e4fe;
}
h1
{
color:orange;
text-align:center;
}
p
{
font-family:"Times New Roman";
font-size:20px;
}
the directory structure for css and jsp's are as follows:
webcontent/welfare_web/css for .css files and
webcontent/welfare_web/login for jsp files
the programming editor is eclipse and the server i am using is tomcat 7.0. when i am trying to run the login.jsp file using tomcat server. The css file is not showing any effect. i mean the output is normal text and is not as per the CSS file.
please help me how to make the .css file to effect the jsp file.
css href link is incorrect. Use relative path instead:
<link href="../css/loginstyle.css" rel="stylesheet" type="text/css">
You can write like that. This is for whenever you change context path you don't need to modify your jsp file.
<link rel="stylesheet" href="${pageContext.request.contextPath}/css/styles.css" />
I use this version
<style><%#include file="/WEB-INF/css/style.css"%></style>
I had the same problem too. Then i realized that in the MainPageServlet the urlPatterns parameter in #WebServlet annotation contained "/", because i wanted to forward to the MainPage if the user entered the section www.site.com/ . When i tried to open the css file from the browser, the url was www.site.com/css/desktop.css, but the page content was THE PAGE MainPage.jsp. So, i removed the "/" urlPattern and now i can use CSS files in my jsp file using one of the most common solutions (${pageContext.request.contextPath}/css/desktop.css).
Make sure your servlet doesn't contain the "/" urlPattern.
I hope this worked for u too,
- Axel Montini
if everything seems correct, and despite it still does not work I invite you to load the statics files in the web.xml like this
<servlet-mapping>
<servlet-name>default</servlet-name>
<url-pattern>/includes/*</url-pattern>
</servlet-mapping>
after
<!-- bootstrap css -->
<link rel="stylesheet" type="text/css" href="/includes/asserts/css/bootstrap.min.css"/>
use this it worked for me
<style><%#include file="/WEB-INF/view/style/style.css"%></style>
For CSS :
<link href="css/bootstrap.css" rel="stylesheet" type="text/css">
For JS :
<script type="text/javascript" src="js/bootstrap.js"></script>
Files location:
└───src
└───main
├───java
└───webapp
├───css/bootstrap.css
├───js/bootstrap.js
├───META-INF
└───WEB-INF/index.jsp
└───lib

Categories

Resources