[caption id="attachment_948" align="aligncenter" width="287"] Flicker[/caption]
[sourcecode language="javascript"]
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<title>Flicker Image Search API Demo</title>
</head>
<body>
Search for <b>girls, dogs, cakes</b> ...etc)
<br />
<input id="searchterm" />
<button id="search">search</button>
<div id="results"></div>
<script>
$("#search").click(function(){
$.getJSON("http://api.flickr.com/services/feeds/photos_public.gne?jsoncallback=?",
{
tags: $("#searchterm").val(),
format: "json"
},
function(data) {
$.each(data.items, function(i,item){
$("<img/>").attr("src", item.media.m).prependTo("#results");
if ( i == 10 ) return false;
});
});
});
</script>
</body>
</html>
[/sourcecode]
Saturday, November 23, 2013
Saturday, November 9, 2013
How to access Session Bean from JSP in GlassFish
Using Session Bean in JSP differs from the usage in servlets. We can inject session bean in servlets or in another session bean. But in JSP we can not use EJB in the same way. Most common approach would be a JNDI lookup to find the required bean.
First add a reference in deployment descriptor to the session bean.
[sourcecode language="xml"]
<ejb-local-ref>
<ejb-ref-name>AccountTypeFacadeRef</ejb-ref-name>
<ejb-ref-type>Session</ejb-ref-type>
<local>com.my.ejb.AccountTypeFacade</local>
<ejb-link>BankApp-ejb.jar#AccountTypeFacade</ejb-link>
</ejb-local-ref>
[/sourcecode]
is optional.
In JSP use JNDI lookup to find the resource.
[sourcecode language="xml"]
<%
String prefix = "java:comp/env/";
String ejbRefName = "AccountTypeFacadeRef";
String jndiUrl = prefix + ejbRefName;
javax.naming.Context ctx = new javax.naming.InitialContext();
AccountTypeFacade atf = ( AccountTypeFacade ) ctx.lookup( jndiUrl );
List<AccountType> accountTypeList = atf.findAll();
%>
[/sourcecode]
First add a reference in deployment descriptor to the session bean.
[sourcecode language="xml"]
<ejb-local-ref>
<ejb-ref-name>AccountTypeFacadeRef</ejb-ref-name>
<ejb-ref-type>Session</ejb-ref-type>
<local>com.my.ejb.AccountTypeFacade</local>
<ejb-link>BankApp-ejb.jar#AccountTypeFacade</ejb-link>
</ejb-local-ref>
[/sourcecode]
is optional.
In JSP use JNDI lookup to find the resource.
[sourcecode language="xml"]
<%
String prefix = "java:comp/env/";
String ejbRefName = "AccountTypeFacadeRef";
String jndiUrl = prefix + ejbRefName;
javax.naming.Context ctx = new javax.naming.InitialContext();
AccountTypeFacade atf = ( AccountTypeFacade ) ctx.lookup( jndiUrl );
List<AccountType> accountTypeList = atf.findAll();
%>
[/sourcecode]
Subscribe to:
Posts (Atom)
How to enable CORS in Laravel 5
https://www.youtube.com/watch?v=PozYTvmgcVE 1. Add middleware php artisan make:middleware Cors return $next($request) ->header('Acces...
-
< Requirements Java Development Kit (JDK) NetBeans IDE Apache Axis 2 Apache Tomcat Server Main Topics Setup Development Environ...
-
Download Sourcecode [sourcecode language="csharp"] using System; using System.Collections.Generic; using System.Linq; using System...