I'm trying to run a very simple app to the new WSO2 AppServer (version 5.0.0) but there seems to be something very odd going on. When I try to access a page that does a simple JNDI lookup, I get the following error:
HTTP Status 500 - org.apache.jasper.JasperException: Unable to compile class for JSP Generated servlet error:
Only a type can be imported. javax.naming.InitialContext resolves to a package
An error occurred at line: 11 in the jsp file: /jndi.jsp
Generated servlet error: InitialContext cannot be resolved to a type
An error occurred at line: 11 in the jsp file: /jndi.jsp Generated servlet error:
InitialContext cannot be resolved to a type
The page contains just the following code:
<!DOCTYPE html>
<%#page contentType="text/html" pageEncoding="ISO-8859-1"%>
<%#page import="javax.naming.InitialContext" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>JNDI Test</title>
</head>
<body>
<h1>JNDI Test</h1>
<%
InitialContext ctx = new InitialContext();
%>
<p>Context: <%= ctx.getNameInNamespace() %>
</body>
</html>
It seems that the tomcat compiler is unable to "see" the java runtime classes, but I can't figure out why.
Any help would be appreciated.
Add the jndi look up code to a seperate java class and invoke it from your jsp page.
Related
This is a single script.php only to load data.
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>TEST</title>
</head>
<body>
<div id="location">
<script src="https://maps.googleapis.com/maps/api/geocode/json?latlng=42.149247222222,24.752305555556&key=My-enabled-key-here">
</script>
</div>
</body>
</html>
In Mac Safari I get I get `SyntaxError: Unexpected token ':'. Parse error.
Several data is loaded I see it in Safari debugger starting in:
but I cannot use it because of that error message.
In Chrome and Opera I get Cross-Origin Read Blocking (CORB) blocked cross-origin response with MIME type application/json.
Reading some old questions I added
<?php header('Access-Control-Allow-Origin: http://example.com') ?>
and then replaced by
<?php header('Access-Control-Allow-Origin: *') ?>
as the first line but nothing changed.
From Google side: Key restrictions
-> Application restrictions: none.
-> API restrictions: yes (key is accepted for 4 APIs, one of them is Geocoding API
What's wrong here?
Since you are making a Geocoding web service request in the client-side (front-end) that's why you are getting the Cross-origin blocking error (CORB). Web service requests are meant to be executed server side.
Note that if you intend to use Geocoding in client-side, the JavaScript API has a Geocoding Service (which prevents the CORB issue). Please refer to this guide: https://developers.google.com/maps/documentation/javascript/geocoding
Hope this helps!
gotemplates
Hello!
I'm learning Go language now and trying to port some simple WEB code (Laravel 4).
Everything was well, until I tried to reproduce Blade templates into text templates.
I found that Go can load my CSS and JavaScript files only from the catalog with a name "bootstrap" only.
Here is my catalog tree which I tried to use:
start-catalog
bootstrap (link to bootstrap-3.3.1)
bootstrap-3.3.1
css
bootstrap.min.css
js
bootstrap.min.js
jquery
jquery (link to jquery-2.1.1.min.js)
jsquery-2.1.1.min.js
go_prg.go
Here are my templates:
base_js.tmpl
{{define "base_js"}}
{{template "login_1"}}
<script src = "/bootstrap/js/jquery"></script>
<script src = "/bootstrap/js/bootstrap.min.js"></script>
{{end}}
base_header.tmpl
{{define "base_header"}}
<head>
<title>PAGE TITLE</title>
<meta name = "viewport" content = "width=device-width, initial-scale=1.0">
<meta charset="utf-8">
<link href = "/bootstrap/css/bootstrap.min.css" rel = "stylesheet">
</head>
{{end}}
If the catalog name differs from "bootstrap" Go language or Firefox can't load files from the templates above: bootstrap.min.css, bootstrap.min.js, jquery.
If I use not the link but the catalog name directly "bootstrap-3.3.1" than Go or Firefox can't load.
If all required files are moved under "bootstrap" I'm getting the results I expected (exactly the same as in Laravel 4).
To launch go language code the command go run go_prg.go was used.
Environment: Ubuntu 14.04, go-1.3.3, Firefox 31.
Who's wrong: Go language, Firefox or me?
Any help will be highly appreciated!
The problem described was caused by
http.Handle("/bootstrap/", http.StripPrefix("/bootstrap/", http.FileServer(http.Dir("bootstrap"))))
before any template was handled. It allowed access files under the directory 'bootstrap' only.
The problem was fixed by changing to
http.Handle( , http.StripPrefix(, http.FileServer(http.Dir("."))))
and adding to pathes for CSS and JavaScript files. Like so
/bootstrap/js/jquery">.
Fatal error: Uncaught exception 'SmartyException' with message 'Unable to load template file '../index/index.tpl'' in
/var/www/docs/sw.com/public/library/Smarty/sysplugins/smarty_internal_template.php:174
Stack trace:
#0 /var/www/docs/sw.com/public/library/Smarty/sysplugins/smarty_internal_template.php(551): Smarty_Internal_Template->isExisting(true)
#1 /var/www/docs/sw.com/public/application/tmp/smarty_compile/898ca70906754084b81f61d3ce7baee3b11bd8d3.file.layout.tpl.php(46): Smarty_Internal_Template->getRenderedTemplate()
#2 /var/www/docs/sw.com/public/library/Smarty/sysplugins/smarty_internal_template.php(436): include('/var/www/docs/s...')
#3 /var/www/docs/sw.com/public/library/Smarty/sysplugins/smarty_internal_template.php(568): Smarty_Internal_Template->renderTemplate()
#4 /var/www/docs/sw.com/public/library/Smarty/Smarty.class.php(328): Smarty_Internal_Template->getRenderedTemplate()
#5 /var/www/docs/sw.com/public/library/Smarty/Smarty.class.php(370): Smarty->fetch('/var/www/docs/s...', NULL, NULL, NULL, true)
#6 /v in /var/www/docs/sw.com/public/library/Smarty/sysplugins/smarty_internal_template.php on line 174
I am using smarty template with zend framework and in that I create one more module like admin.In that module Controller is working and layout.tpl file is also working but problem is that when i add include file syntax in layout.tpl file that time same error is coming.
IndexController.php
<?php
class Admin_IndexController extends Models_UserCommonController
{
function init()
{
parent::init();
}
public function indexAction()
{
$this->view->assign('T_Body', '../index/index.tpl');
}
}
?>
layout.tpl
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252" />
<title>{$SITE_TITLE}</title>
</head>
<body>
<p>Hello</p>
{include file="$T_Body"}
</body>
</html>
index.php
Admin
I done same thing in windows its working but in ubuntu its not working.
I set all permissions and check everything path and all.
Default module is working in ubuntu but admin module is not working
Not too sure about the Smarty implementation but you have to remember that PHPs working directory is your projects root path.
You'd probably want to assign it absolutely with this manner:
$this->view->assign('T_Body', __DIR__ . '/../index/index.tpl');
Remember though that this only holds true for Zend Framework 2! Your code suggests that you're not using the second version but rather ZF1. Otherwise you absolutely should move forward and use namespaces and follow the tutorial on how to build your Controllers.
I have to make a Web Application for downloading files from a folder.I use Tomcat as a server.I wrote a JSP page for listing the content of my data folder,and I tried to make links for each file from this folder.
The JSP page is this:
<%# page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1" import="java.io.File,java.io.IOException,java.util.*,java.io.*" %>
<!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>Insert title here</title>
</head>
<body>
Contents <br>
<% File f = new File("C:\\Users\\name\\Desktop\\eclipse\\app\\PTW\\WebContent\\data\\"); // current directory
File[] files = f.listFiles();
for (File file : files) {
if (file.isDirectory()) {
//System.out.print("directory:");
} else {
%>
<a href="<%=file.getAbsolutePath()%>" target="_blank"><br> <%=file.getName() %>
</a>
<%
}
}
%>
</body>
</html>
The problem is that downloading these files is working only in I.E. and only if user selects Right CLick - Save target As.
So my way to do this is wrong!But I don't understand why?How to force downloading files from this JSP?
Thank You!
You must know that the path to the file on the file system is a different path than the URL. The file system is only known by your server, the URL is the path which is accessed by browsers.
Let's say your file is in /opt/tomcat/webapps/myApp/folder/file.jpg and you are running your Tomcat on www.example.com. If you generate (through JSP) a link like
Download File
Your browser will see this path as:
www.example.com/opt/tomcat/webapps/myApp/folder/file.jpg
Your browser will not find the file. The URL the browser would neet to find it is:
www.example.com/myApp/folder/file.jpg
Which consists of
the domain www.example.com
the servlet context myApp
the path inside the application to the file folder/file.jpg
So you need to build the path /myApp/folder/file.jpg in your JSP. You can do it this way:
Download
I use Expression Language here instead of scriptlets. This is considered better style as it improves maintaineance and readability.
Note: This will only work if your File is inside the webapplication directory (myApp). If it is outside, you will need a servlet to stream your files to the client, but that is an other story.
I have an error page,anyError.cfm, that looks like this
<!DOCTYPE html>
<html>
<head>
<title>Error</title>
</head>
<body>
<p>An error has occurred.</p>
</body>
</html>
In the CF web admin under Server Settings > Settings > Site-wide Error Handler I enter \anyError.cfm. When I navigate to http://localhost:8500/some-url-that-doesnt-exist I still get the default error page. So my question, how do I get a custom site-wide error page using CF9? It doesn't necessarily have to be through the web admin.
Edit:
Try using the value "anyError.cfm" instead of "\anyError.cfm" in the site-wide error handler setting.
Update, after seeing your update to your question I see now that you are generating a 404. Which is not for the site-wide error handler, it is for the missing template handler setting right next to it.
Try using a variable that doesn't exist instead to generate an error that will cause the site-wide error handler to display.