JSP is not parsing page directive - spring

JSP is not getting parsed on browser. Instead show the directive directly.
Can anyone help me out
<%# 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>
<title>
Sample
</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
</head>
<body>
<button id="generateTicket">Generate Ticket</button>
<div id='ticket'></div>
<script>
$("#generateTicket").click(
function(){
console.log("Generate ticket");
$("#ticket").load("generateTicket");
});
</script>
</body>
</html>
below is the image of pom.xm

Related

Unable to load css/js files in a spring project

I have tried 2 ways to load external css or js files in my spring project but neither of them is working fine.
Home.jsp
<%# page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%#taglib uri="http://java.sun.com/jstl/core" prefix="c"%>
<%#taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<!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">
<link rel="stylesheet" type="text/css"
href="/resources/css/font-awesome.min.css" />//NOT LOADING
<link rel="stylesheet" href="<c:url value="resources/css/style.css"/>" />//Not loading Method tried 1
<link rel="stylesheet"
href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<link rel="stylesheet" href="/resources/css/style.css">//Not loading Method tried 2
<script
src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"> </script>

Unable to call modelMap in JSP

I have a Spring MVC controller which maps test to test.jsp. It has ModelMap object which has to be accessed by JSP page.
Here is controller
#RequestMapping(value = "/test")
public String test(ModelMap map)
{
map.addAttribute("data","the string which should bbe printed");
return "test";
}
Here is test.jsp
<%# page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Hello</title>
</head>
<body>
<c:out value="${data}" />
</body>
</html>
I am getting nothing on the screen.
Please help me out.

unable to pass variables between jsp templates

I'm unable to pass variables from a.jsp to b.jsp, following is what I tried and the output. Can someone please help? Thanks.
a.jsp
start including
<jsp:include page="b.jsp">
<jsp:param name="somevar" value="zzzz" />
</jsp:include>
stop including
b.jsp
${somevar}
${param.somevar}
<%=request.getParameter("somevar")%>
output
start including
null
stop including
You have to set your param before include.
start including
<jsp:params>
<jsp:param name="somevar" value="zzzz" />
</jsp:params>
<jsp:include page="b.jsp">
</jsp:include>
stop including
And can u try this in b.jsp:
<%=request.getParameter("somevar");%>
What is output?
Try the following code:
home.jsp
<%# taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%# page session="false"%>
<html>
<head>
<title>Home</title>
</head>
<body>
<h1>Hello world!</h1>
<jsp:include page="b.jsp">
<jsp:param name="something" value="something" />
</jsp:include>
<h1>Bye World</h1>
</body>
</html>
In the b.jsp page use the following code.
<%# page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%# taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!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>JSP Param example</title>
</head>
<body>
<h1>
<c:out value="${param.something}" />
</h1>
</body>
</html>
The output must be
Hello world!
something
Bye World
Try to avoid java code in JSP pages as it is not advisable. For more details, have a look at this answer How to avoid Java Code in JSP-Files?

kendoEditor doesn't appear

Here is my code:
<%# Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="kendo_UI.WebForm1" %>
<!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 runat="server">
<title></title>
<link href="~/Styles/kendo/kendo.common.min.css" rel="stylesheet" />
<link href="~/Styles/kendo/kendo.default.min.css" rel="stylesheet" />
<script type="text/javascript" src="~/Scripts/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="~/Scripts/kendo/kendo.all.min.js"></script>
</head>
<body>
<form id="form1" runat="server">
<div>
<textarea id="editor" rows="10" cols="30"> </textarea>
<script type="text/javascript">
$(document).ready(function () {
$("#editor").kendoEditor();
});
</script>
</div>
</form>
</body>
</html>
But textarea appears without kendoEditor :-(
What's wrong?
Thank you!
And no more details ;-(
Kendo UI doesn't work with jQuery 1.9.x. You need to include jQuery 1.8.2. More info can be found in the documentation.

Visual Studio 2005 - asp.net image display problem

I can see background images in design time. But can't see images in run time. I am running my application from asp.net development server.
I am applying background images by using css.
What is the solution?
<%# Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="BackgroundImageTest._Default" %>
<!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 runat="server">
<title>Untitled Page</title>
<link rel="stylesheet" href="Stylesheet1.css" type="text/css" media="screen" />
</head>
<body>
<form id="form1" runat="server">
<div>
abcdef
</div>
</form>
</body>
</html>
div
{
background-image:url(App_LocalResources/database.1.jpg);
width:400px;
height:400px;
}
Did you check if the PATH is still there in runtime ?

Resources