xmlns:th="http://www.thymeleaf.org" cannot be fetch by intellij - java

I am learning spring boot and there is a problem in my thymeleaf template.
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<div th:if="${message}">
</div>
</body>
</html>
When i fetch the external resource, there is an invalid URL exception saying: No XML at the specified location: http://www.thymeleaf.org
The dependency in maven is imported. I am using Intellij Community 2021.3.2

I was having the same issue in IntelliJ and I fixed it with this solution:
Navigate to the following File > Settings > Plugins
From here you will search "ThymeLeaf" once you do "JBLHtmlToThymeLeaf" will come up
Install it
Then go to your HTML file, right click it and select "JBLHtmlToThymeleaf"
This will add namespace(xmlns:th="http://www.thymeleaf.org") attribute to HTML tag.

Related

javax.el.ExpressionFactory.newInstance() not found on Jetty and Java 7

I have this JSP:
<%# page pageEncoding="UTF-8" %>
<%# taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<c:set var="contextPath" value="http://localhost:8000/"/>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=Edge" />
<link type="text/css" rel="stylesheet" href="${contextPath}/css/styles.css"/>
</head>
<body>
<!-- some html -->
</body>
When I navigate to this page, I get next error:
java.lang.NoSuchMethodError: javax.el.ExpressionFactory.newInstance()Ljavax/el/ExpressionFactory;
at org.apache.jasper.compiler.JspUtil.getExpressionFactory(JspUtil.java:1182)
at org.apache.jasper.compiler.JspUtil.validateExpressions(JspUtil.java:644)
at org.apache.jasper.compiler.Validator$ValidateVisitor.visit(Validator.java:752)
at org.apache.jasper.compiler.Node$ELExpression.accept(Node.java:946)
at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2291)
at org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2341)
at org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2347)
at org.apache.jasper.compiler.Node$Root.accept(Node.java:498)
at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2291)
[...]
The environment to execute this page is Java 7 and Jetty.
If I remove ${contextPath} works fine.
Why i have this error?
Best regards
The cause of your error is 2 different EL language jars in your classpath.
EL version 2.1 is what is actively being used by your webapp, and is the cause of your error (that method doesn't exist in EL 2.1)
EL version 2.2 is what your webapp needs to be using for javax.el.ExpressionFactory.newInstance(), as that method was introduced in EL 2.2
Make sure you are using the correct version of the EL lib, and that you don't have multiple versions of it present in your webapp
Also, why not just use ...
<link type="text/css" rel="stylesheet"
href="${pageContext.request.contextPath}/css/styles.css"/>
and skip the whole <c:set> you are using? (your choice of a fully qualified URI is a bad idea anyway)

Display static google map location in android application

Here is my code for displaying static google map in android application using html,But when i open the activity it shows blank.
please help me to solve the issue,im new in android,
JAVA
WebView overview = (WebView) findViewById(R.id.googlemap_webView);
overview.loadUrl("file:///android_asset/content/googlelocation.html");
googlelocation.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<iframe width="600" height="450" frameborder="0" style="border:0" src="https://www.google.com/maps/embed/v1/place?q=Crescent%20Builders%2C%20Cherooty%20Road%2C%20Vellayil%2C%20Calicut%2C%20Kerala%2C%20India&key=AIzaSyCeBlSt-PVun7-08LrM6mIS5Nd0NCRVpDM"></iframe>
</body>
</html>
Static maps have been added in the last version of Google Maps for Android. See https://developers.google.com/maps/documentation/android/lite
Unless you have a good reason to use the web version, Android specific one will work better.

Offline cache using manifest appcache

I am trying to make my application offline enabled.
This is my starting page of the app which I have put on TOMCAT
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html manifest="test.appcache">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
Hello World
</body>
</html>
And Here is my test.appcache (although I am not using any of the files mentioned in my manifest files at this point - its just a POC)
CACHE MANIFEST
#version 821
CACHE:
test.html
/resources/test.js
NETWORK:
*
FALLBACK:
test.html
test.html runs fine in online mode in localhost:8080/myapp/test.html
But when I stop the TOMCAT and try to run it
this is what I get -
Why is my HTML page test.html not getting served from cache when I stop TOMCAT server!
Thanks
Try changing the doctype of your HTML doc to
<DOCTYPE html>
the manifest attribute is HTML5.
https://developer.mozilla.org/en-US/docs/Web/HTML/Using_the_application_cache

Applet Class Not Found Error

i have just started learning jsp, i came across running Applet from jsp, the code below doesn't seems to work.
<%# page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!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=ISO-8859-1">
<title>InfoVisual</title>
</head>
<body>
<jsp:plugin type="applet" codebase="WEB-INF/classes" code="DemoApplet.class" width="400" height="400">
<jsp:fallback>
<p>Unable to load applet</p>
</jsp:fallback>
</jsp:plugin>
<input name="btnShow" value="Show" type="submit">
</body>
</html>
My eclipse project structure is like below
I don't know why i can't see the applet running.
Have i placed files in right folders???
Classes in WEB-INF/classes are only visible to server-side code such as servlets. Instead create a JAR file containing the compiled classes required to run the applet are place them in the same location as the JSP file. The plugin tag will then look like
<jsp:plugin type="applet" code="DemoApplet.class" archive="MyAppletJar.jar" width="400" height="400">
<jsp:fallback>
<p>Unable to load applet</p>
</jsp:fallback>
</jsp:plugin>
this code worked perfectly:
<applet code="DemoApplet.class" name="DemoApplet" archive="DemoApplet.jar" width=300 height=300>
</applet>
and here is my project structure:
Thanx for the help :))

Package Beans does not Exist

I am a .NET developer dabbling into the JSP world. I loaded NetBeans 6.5.1 and get an error in this page:
<%#page import="java.io" %>
<%#page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"w3.org/TR/html4/loose.dtd">;
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<h1>Hello World!</h1>
</body>
</html>
the error is:
"Package Beans does not Exist"
I should add that I created a new Java Web Application and then copy-and-pasted some code that called for the above import. then I get the error.
Help with this error would be great along with any tutorials or books.
Something is wrong with the classpath. Your configuration of the server, plus setup in the WAR file, should be checked against a working one.

Categories