Access bean
I have a JSP and I need acces bean, the bean is saved in WEB-INF/classes/paquete/
I use then next sentence:
<jsp:useBean id="queryBean" class="paquete.beanExample" scope="session" />
the class compile OK, but when I call the JSP appaers the next error:
Error: Unable to find class for bean: queryBean defined by tag with class: paquete.beanExample.
Where I must put the class ??
For connection I use:
<%@ page import="java.sql.*, javax.sql.*, oracle.jdbc.pool.*" %>
<jsp:useBean id="ods" class="oracle.jdbc.pool.OracleConnectionCacheImpl" scope="session" />
and not have problems.
If I use
<%@ page import="mypackage1.*" %>
<jsp:useBean id="queryBean" class="mypackage1.DynamicQueryBean" scope="session" />
the same error appaers
Thanks,
MIGUEL ANGEL CARO
[email protected]
I'm using JDK 1.3, in the directory web-inf/classes/ I put the class (DynamicQueryBean.class),
first I import and next declare the JavaBean, the code is:
<%@ page import="DynamicQueryBean" %>
<jsp:useBean id="queryBean" class="DynamicQueryBean" scope="session" />
in the second line the error is:
Unable to find class for bean: queryBean defined by tag with class: DynamicQueryBean
Similar Messages
-
Portal runtime error: Cannot access bean property
Dear all,
Does anybody have a clue what problem might couse the <b>Portal Runtime Error</b> described below?
It does seem to occur when a second user wants to access the <b>Component</b>.
<b>Portal Runtime Error</b>
An exception occurred while processing a request for :
iView : pcd:portal_content/com.xxxxx.luminaires/com.xxxx.iviews/Quotations/EasyQuote
<b>Component</b> Name : EasyQuoteDemo.EasyQuoteComponent
Tag tableView attribute model: Cannot access bean property quotationHeader.CurrentTableModel in page context.
Exception id: 04:50_21/09/04_0070
See the details for the exception ID in the log file
Thxs in advance
JoostHi Dominik,
Having a closer look at the problem, we found it is not the number of users.
It seems our JAVA components keeps the conenctions with SAP open and reopens a new one every time we start the component.
If we finished solving the problem, I will publish the solution.
Greetings,
Joost -
Help:accessing beans method
hello
i have made one application in which i have made two beans under different packages. i am trying to access beans through jsp pages. i am able to access beans and their methods but when i add new method in bean and tried to access that method with different new jsp page say page1.jsp. I am not able to access new method though i am able to access old methods of same beans with this new jsp page. then i made new bean and copied that method in this new bean . then i tried to access that method of this new bean with page1.jsp and i am able to access it can any body guide me what is the reason for this. i want to run this method in old beran rather than new bean
my directory structure is:
projectlms---main folder
addstream---old jsp page
page1---new jsp page
web-inf/classes
com-------main packageof beans
ProgramManager----sub package of classes
bean1--------old bean
new bean------new bean just for testing
now the problem is that i want to add one more method to bean1 and want to access it through pag1.jsp
but i am not able to access it and same method when i take to new bean i am able to access that method through page1.jsp
but i am able to access old methods of bean1 through page1.jsp
thanks
regards
vivekCould be a caching issue.
Wipe out the COMPILED jsps and try again. -
Access bean(wrapper) for EJB
How can I develop access bean(wrapper) for EJB in JDeveloper?
Search the Internet for a product called JACOB
JAva COm Bridge -
Server Shows : Error in Accessing Beans
here it shows the error as "Error in Accessing Beans".Anybody knows solutions pls give solutions for this.
Hi Visakh,
Yes,The user is holding the permission as "Global User" in sql.Hope you help me in solve this issue
Thanks, Quality Communication Provides Quality Work. http://siddiq-sharepoint2010.blogspot.in/ Siddiqali Mohammad .
Hi siddiqali,
According to the screenshot you posted above, the use account didn't have sufficient permission to open the report, please check the following prerequisites before you perform the action:
You must use a report definition (.rdl) file as a data source. Importing from a report model is not supported.
You must have permission to open the report under your Windows user account, and you must know the address of the report or the report server that hosts it. You can check your permissions by trying to open the report in a Web browser first.
If the report opens, it confirms that you have sufficient permissions and the correct URL.
Reporting Services must be version SQL Server 2008 R2 or SQL Server 2012. Those versions include the data feed export feature that streams report data in the XML data feed format. You can identify the report server by the Export as Data Feed option
that appears in the report toolbar when you open the report in browser:
For detail information, please see:
Import Data from a Reporting Services Report:
http://technet.microsoft.com/en-us/library/gg413491.aspx
Regards,
Elvis Long
TechNet Community Support -
Hi,
I am setting few values in a bean class and trying to access the values through get from another class, i am not getting those values.
Is there any way to make that bean -which is used during set operation be accessible to entire package?
Regards,
VenkyYour describe is doubt
In my Opinin
You hava a bean (just named "A"),and another bean (named "B")
and you set few values in A,then you want to get them in B
if you had create a object with the type A,you can get the values from the object's getter methods
At last makesure the getter methods were declared as public -
hi to all,
i created a simple bean for login access that has getter and setter method...
I am trying to access the bean in a servlet .. i got error....
my bean code is ...
simple login page
<form method="post" action="/BeanServlet">
user Name :
<input type="input" name="username" >
Password :
<input type="password" name="password" >
<input type="submit" value="submit" >
</form>
package use;
public class UserData {
String username;
String password;
public void setUsername( String value )
username = value;
public void setPassword( String value )
password = value;
public String getUsername() { return username; }
public String getPassword() { return password; }
please fill in the Servlet code is
response.setContentType("text/html");
PrintWriter out = response.getWriter();
HttpSession session = request.getSession();
UseData ud = (UserData) session.getAttribute();
????? what comes here
out.println(ud.getPassword(););
out.println(ud.getUsername());sorry kannankalli, but this is what i understood from your question, that you want to take the information of a form from a servlet,,
and this is the servlet code:
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.*;
import javax.servlet.http.*;
public class Servlet extends HttpServlet {
private static final String CONTENT_TYPE = "text/html; charset=windows-1252";
public void init(ServletConfig config) throws ServletException {
super.init(config);
public void doPost(HttpServletRequest request,
HttpServletResponse response) throws ServletException,IOException {
String retrievedUserName = request.getParameter("userNameField");
String retrievedPassword = request.getParameter("passwordField");
response.setContentType(CONTENT_TYPE);
PrintWriter out = response.getWriter();
out.println("<html>");
out.println("<head><title>Servlet</title></head>");
out.println("<body>");
out.println("<p>The userName is: </p>" + retrievedUserName);
out.println("<p>The password is: </p>" + retrievedPassword);
out.println("</body></html>");
out.close();
notice request.getParameter("userNameField"); the userNameField is the same name as the textField in the html page, and so the password...
I hope i reached your point..(^_^); -
Error in jsp accessing beans in OSE
I have an application with jsps and ejbs I am trying to run from OSE. (Solaris8/9iAS)
The beans &jsp have been loaded to database and the jsps have been published
When the jsps try to access the beans I get the following error
-- The message of the exception is
Could not instantiate adapter: java.lang.NullPointerException
org.omg.CORBA.OBJ_ADAPTER: Could not instantiate adapter: java.lang.NullPointerException minor code: 0 completed: No
From previous topics posted to this Forum others have experienced similar problem.
Would appreciate any help.
Thanks in advance.refresh
<BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by DG:
I have an application with jsps and ejbs I am trying to run from OSE. (Solaris8/9iAS)
The beans &jsp have been loaded to database and the jsps have been published
When the jsps try to access the beans I get the following error
-- The message of the exception is
Could not instantiate adapter: java.lang.NullPointerException
org.omg.CORBA.OBJ_ADAPTER: Could not instantiate adapter: java.lang.NullPointerException minor code: 0 completed: No
From previous topics posted to this Forum others have experienced similar problem.
Would appreciate any help.
Thanks in advance.<HR></BLOCKQUOTE>
null -
Hi all,
I am having some problems accessing JavaBeans from my servlets, but I can access them from my JSP page(i used the import command, <%@ page import="servlets.myBeans.login.User" %>, and it works).
I have placed my User bean in the following package
\webapps\ROOT\WEB-INF\classes\servlets\myBeans\login
Here's the java code for User Bean
package servlets.myBeans.login;
* A simple Java Bean for users.
public class User implements java.io.Serializable{
private String username = null;
private String password = null;
public User() {}
public User (String u, String p) {
username = u;
password = p;
public String getUsername() {
return username;
public void setUsername(String username) {
this.username = username;
public String getPassword() {
return password;
public void setPassword(String password) {
this.password = password;
public String toString() {
return username + ":" + password;
This compiles and creates a class file.
My servlet LoginControlServlet is in the following path
\webapps\ROOT\WEB-INF\classes\servlets
when I try to compile this servlet i get the following errors
C:\jakarta-tomcat-4.1.1.12-LE\jakarta-tomcat-4.1.24-LE-jdk14\webapps\ROOT\
WEB-INF\classes\servlets\LoginControlServlet.java:18:
cannot resolve symbol
symbol : class User
location: class servlets.LoginControlServlet
User up = (User)session.getAttribute("up");
^
C:\jakarta-tomcat-4.1.1.12-LE\jakarta-tomcat-4.1.24-LE-jdk1\webapps\ROOT
\WEB-INF\classes\servlets\LoginControlServlet.java:18:
cannot resolve symbol
symbol : class User
location: class servlets.LoginControlServlet
User up = (User)session.getAttribute("up");
^
C:\jakarta-tomcat-4.1.1.12-LE\jakarta-tomcat-4.1.24-LE-jdk1\webapps\ROOT
\WEB-INF\classes\servlets\LoginControlServlet.java:27:
cannot resolve symbol
symbol : class User
location: class servlets.LoginControlServlet
up = new User(user,pass);
^
3 errors
I have already included the \webapps\ROOT\WEB-INF\classes in my class path
infact, I have even included \webapps\ROOT\WEB-INF\classes\servlets and
\webapps\ROOT\WEB-INF\classes\servlets\myBeans\login in my classpath.
Any ideas, as to why I am having the above errors.
thanks,
manishI think it's pretty much got to be a compile time classpath problem. Either your bean is compiling to a funny place, or you classpath is wrong when you compile the servlet. Probably the latter if your jsp picks it up OK.
The entry in the classpath should be
<tomcat directory>/webapps/ROOT/WEB-INF/classes
Check the syntax carefully.
putting package directories on your classpath can only confuse things.
Make sure that ...../webapps/servlets/myBeans/login/User.class exists. -
Accessing bean properties in a jsp
Hi,
I am trying to access a bean in my jsp page like this,
<c:out value="${clientSession.customerName}"/>
I validate and then set the bean in my action class, I am using struts 1.1,
package com.neo.five.ereports;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionForm;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpSession;
import com.neo.five.cookies.SessionCookieValidator;
import com.neo.five.beans.CustomerSessionBean;
public final class EreportAction extends Action{
public ActionForward execute(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response){
//get the session object
HttpSession session = request.getSession(false);
//validate the session cookie if session object dows not exist
Cookie[] cookies = request.getCookies();
SessionCookieValidator scv = new SessionCookieValidator(cookies);
scv.checkCookie();
//forward to appropriate destination
//if there is a cookie continue
if(scv.hasSessionCookie()){
//check for session object
if (session != null) {
//if session does not exist put bean into session that holds the cookie
//values
if(session.getAttribute("cookieSession")==null){
CustomerSessionBean sb = new CustomerSessionBean(scv.getCustomerid(),scv.getCustomerName(),scv.getCfid(),scv.getCftoken());
session.setAttribute("cookieSession", sb);
request.setAttribute("clientSession",sb);
return (mapping.findForward("success"));
}else{
return (mapping.findForward("failure"));
}else{
return (mapping.findForward("failure"));
}this is my SessionBean
package com.neo.five.beans;
public class CustomerSessionBean {
private int customerid;
private String customerName;
private int cfid;
private int cftoken;
public CustomerSessionBean(int customerid,String customerName,int cfid,int cftoken){
this.customerid=customerid;
this.customerName=customerName;
this.cfid=cfid;
this.cftoken=cftoken;
public int getCustomerid(){
return customerid;
private String getCustomerName(){
return customerName;
private int getCfid(){
return cfid;
private int getCftoken(){
return cftoken;
}however I am getting this error,
HTTP Status 500 -
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: An error occurred while evaluating custom action attribute "value" with value "${clientSession.customerName}": Unable to find a value for "customerName" in object of class "com.neo.five.beans.CustomerSessionBean" using operator "." (null)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:254)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:684)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:432)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:356)
at org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1069)
at org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:455)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:279)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:507)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2422)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:163)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:199)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:828)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:700)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:584)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
at java.lang.Thread.run(Thread.java:536)
root cause
javax.servlet.ServletException: An error occurred while evaluating custom action attribute "value" with value "${clientSession.customerName}": Unable to find a value for "customerName" in object of class "com.neo.five.beans.CustomerSessionBean" using operator "." (null)
at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:533)
at org.apache.jsp.eReportDeskTopRoot_jsp._jspService(eReportDeskTopRoot_jsp.java:145)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:137)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:210)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:684)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:432)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:356)
at org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1069)
at org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:455)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:279)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:507)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2422)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:163)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:199)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:828)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:700)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:584)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
at java.lang.Thread.run(Thread.java:536)
Apache Tomcat/4.1.30
thanks for any help.how?.... mmmm ... did ... (head scratch) ...I miss that.
Thanks a million for spotting that, I really did appreciate that.
jp. -
Accessing bean attributes in a JSP
Hi,
I am sending a bean from a Servlet to a JSP as follows:
request.setAttribute("newclientTEST", ro_client);
this.getServletContext().getRequestDispatcher("/jsp/private/research/UserAdded.jsp").forward(request,
response);I can then access the bean in UserAdded.jsp page as follows:
<jsp:getProperty name="newclientTEST" property="username" />This works fine and returns the username from the bean but I am a little confused why this is working. From what i have read about JSPs so far in order to access properties of a bean in a JSP we first of all have to make a reference to the bean as follows:
<jsp:useBean id="newclientTEST" scope="request" class="ie.scourced.beans.PrivateClientBean" />Why does it work for me when I don't refer to the bean using useBean??
Thankshow?.... mmmm ... did ... (head scratch) ...I miss that.
Thanks a million for spotting that, I really did appreciate that.
jp. -
Possible to access bean property without Java Bean conventions?
Hello,
I'd like to show a component whenever there is an error message in the Faces context. Naively, I set the component's "rendered" attribute to the following:
rendered="#{facesContext.messages.hasNext}"
The object returned by facesContext.messages is an iterator, the properties of which do not follow Java Bean naming conventions. If there was a method called getHasNext() then all would be well. However as it stands, EL cannot evaluate this expression.
I realise that wrapping this up in a managed bean would solve the problem, but I'd like to avoid this if I am able to do this directly from EL.
Cheers,
ChrisHi Juergen,
hasNext actually returns a boolean which EL understands fine. In the end I just wrapped the call within a managed bean, as you suggested, and this works a treat:
public boolean getHasMessages() {
// hasNext will return true if there are any messages to be displayed
return FacesContext.getCurrentInstance().getMessages().hasNext();
}I suppose I felt compelled to post this entry since I found myself having to write some code for an expression that could be written perfectly well in EL but was limited only by the fact that EL can only access properties that follow the Java Bean convention.
I thought that may have been some qualifier or method wrapper I could have used to mean 'take this property name literally'. Alas, it seems no such faclility exists.
Thanks for taking the time to reply,
Chris. -
Some questions about my database access bean
The following is a bean (minus imports) that access a database and populates several "articles" and then returns a set of them. pretty plain really.
The bean is modified from here to add exception cactching and 'fix' other problems along the way.
http://forum.java.sun.com/thread.jspa?threadID=727979 (thanks evnafets)
The results list is genericified(!) to avoif unchecked calls (casting) in this line result.add(article);
public class dataAccess {
public List getNewsResults() throws NamingException{
Context initContext = new InitialContext();
Context envContext = (Context) initContext.lookup("java:/comp/env");
DataSource ds = (DataSource) envContext.lookup("jdbc/mySite");
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
List<newsArticleBean> result = new ArrayList<newsArticleBean>();
try {
String sql = "SELECT * FROM news, users WHERE news.user = users.username";
conn = ds.getConnection();
stmt = conn.createStatement();
rs = stmt.executeQuery(sql);
stmt.execute();
while (rs.next()) {
newsArticleBean article = new newsArticleBean();
article.setTitle(rs.getString("title"));
article.setAuthor(rs.getString("author"));
article.setEmail(rs.getString("email"));
article.setNews(rs.getString("news"));
article.setPictureURL(rs.getString("pictureURL"));
article.setDate(rs.getDate("date"));
article.setTime(rs.getTime("time"));
result.add(article);
} catch (SQLException e) {
//error message goes here
finally {
try {
if (rs != null) rs.close();
} catch (Exception e) {
//error message goes here
try {
if (stmt != null) stmt.close();
} catch (Exception e) {
//error message goes here
try {
if (conn != null) conn.close();
} catch (Exception e) {
//error message goes here
return result;
}Some questions that would be of great help if answered:
Im not too sure what a context does or what im doing with it here. My current understanding is that it allows concurrent access of the database.
Context initContext = new InitialContext();
Context envContext = (Context) initContext.lookup("java:/comp/env");
DataSource ds = (DataSource) envContext.lookup("jdbc/mySite");This section im having trouble with too.
As I see it:
I set what my sql query will be;
get a connection @ conn
now im not too sure what stmt is getting, is it getting ready to send the query.
stmt does not have an executeQuery() method, so im never actually sure when the sql query gets sent to the database. I have subbed with execute() but it does not take any arguments so the problem of not sending anything remains.
String sql = "SELECT * FROM news, users WHERE news.user = users.username";
conn = ds.getConnection();
stmt = conn.createStatement();
rs = stmt.executeQuery(sql);Any help greatly appreciated.Some questions that would be of great help if
answered:
Im not too sure what a context does or what im doing
with it here. My current understanding is that it
allows concurrent access of the database.
Context initContext = new InitialContext();
Context envContext = (Context)
Context) initContext.lookup("java:/comp/env");
DataSource ds = (DataSource)
aSource) envContext.lookup("jdbc/mySite");
Nops, it has nothing to do with concurrent access. You use tomcat to set up a Connection Pool. This causes the tomcat server to create a pool of reusable connections on startup. The connection pool (or set of Connection objects) are given a name and the server binds the set of objects to this name in a 'registry'.
From the code, you use jndi to access the Connections from the pooled objects. While doing so, you have to provide the jndi name against which this object pool is bound to.
You'll be more clear when you read the fllowing resources.
http://java.sun.com/products/jndi/
http://tomcat.apache.org/tomcat-5.5-doc/jndi-datasource-examples-howto.html
>
This section im having trouble with too.
As I see it:
I set what my sql query will be;
get a connection @ conn
now im not too sure what stmt is getting, is it
getting ready to send the query.Yes something of that sort - basically it provides you a wrapper which can accept your query, use the connection object to access the db, execute the query and return a result set.
stmt does not have an executeQuery() method, so im
never actually sure when the sql query gets sent to
the database.er....it has and that's what you use in your code. (http://java.sun.com/j2se/1.5.0/docs/api/java/sql/Statement.html#executeQuery(java.lang.String))
I have subbed with execute() but it
does not take any arguments so the problem of not
sending anything remains.Hmmm....the execute() method is for a different purpose and it does accept arguments (http://java.sun.com/j2se/1.5.0/docs/api/java/sql/Statement.html#execute(java.lang.String))
>
String sql = "SELECT * FROM news,
users WHERE news.user = users.username";
conn = ds.getConnection();
stmt = conn.createStatement();
rs = stmt.executeQuery(sql);Any help greatly appreciated.ram. -
Access bean events data with axbridge ?
I build a bean and packaged with axbridge
It works in c# but how can I get data from my Events ?
I defined a listener in my bean
public interface TestChangedListener extends EventListener{
void testChanged(TestChangedEvent e);
and in c# the method for the delegate is transformed by
void c_testChanged(object arg0) {}
How can I cast arg0 in TestChangedEvent to access event data ?
Thanks
Bruno, ParisBruno,
If you have an event class that looks like this:
public class TestChangedEvent
private String newValue;
public String getChangedValue()
return newValue;
}and you bundle it together with the class for which you produce the activeX, you should be able to access the content of the event with the following code (which is some kind of reflection on the C# side).
Object newValue = t.InvokeMember("getChangedValue", BindingFlags.InvokeMethod, null, e.arg0, null);Hope it helps (if it's not too late)!
Kriket -
Access bean error, urgent.
I want to access a bean from my JSP. I am using Tomcat 4.1.
I put my class file in /web-inf/classes. Please tell me what's wrong?
This is the part in my jsp:
<jsp:useBean id="myBean" scope="session" class="MyBean" />This is the error message
The server encountered an internal error () that prevented it from fulfilling this request.
exception :
org.apache.jasper.JasperException: Unable to compile class for JSP
An error occurred at line: 50 in the jsp file: /index.jsp
Generated servlet error:
[javac] Compiling 1 source file
D:\Tomcat\work\Standalone\localhost\myApp\index_jsp.java:98: cannot resolve symbol
symbol : class MyBean
location: class org.apache.jsp.index_jsp
MyBean myBean = null; This is my Bean class
public class MyBean
static final String BEAN_INFO = "MyBean";
public MyBean()
public String getBeanInfo()
return BEAN_INFO;
}If you are using jdk1.3, then add this directive to
your jsp.
<%@ page import="MyBean" %>
And if you are using jdk1.4 then you need to put your
bean in a package and use,
<jsp:useBean id="myBean" scope="session"
class="package_name.MyBean" />AH HAH! That's why the first version doesn't work for me! I'm using JDK 1.4.1! But the books I've been reading cover 1.3! I was wondering about that! (Why is Java never backwards compatible?)
Don't forget to mention that the package has to be in the correct package directory/folder. In this case:
WEB-INF/classes/package_name/MyBean.class
It may be obvious for Java Gurus, but it bears repeating for us newbies! -
Accessing bean using its Local interface
Hi,
I have a problem accessing a bean using its local interface in J2EE1.3 environment on J2EE test server. I have two beans, one trying to access other, residing in two different ears. During deployment, after I select "Local" interface option in EJB-refs tag of the standard deployment tool of J2ee, it does not show me the bean-name in the "Enterprise Bean Name" combo-box. When I put the name of the actual bean in the box and try to deploy it, gives the null-pointer exception for the above tag as it does not find the corresponding ejb to be referred.
Is it necessary to have a client bean and actual bean to be in the same ear for local interface access? The specifications says that both the beans must be in the same container that does not mean same ear, right????
Thanksi am having the exact same problem now.
did anyone solve this.(you can email [email protected])
Maybe you are looking for
-
hi all, how to handle errors in bapis,and also can anyone send faqs on bapis.
-
I want to change my iPod mini's name!
See subject. Have had a rethink, and now want to change the name of my iPod mini. But how? Nothing when I selected iPod Options... after right-clicking Hynzy's iPod mini (the name of my iPod mini) in iTunes 4.9 for Windows. Help me please!
-
SPA2002 Cannot establish connection!!
I have an SPA2002 behind an RVS4000 router. Spa2002 firmware version is 3.1.18. The adapter is connected to a high priority qos port. Proxy access is enabled. When I lift up the receiver there is a dial tone so the registration is ok, but the calls a
-
When I plug my iPad into my laptop it doesn't pick it up on iTunes?
When I plug my iPad into my laptop it doesn't pick it up on iTunes?
-
Hi, I am very new to Workflow and have just read few basics etc. Now I have been assigned to create some notifications etc for my project. But I am stuck in the initial point only. Beow is the description of the same. Actually I have created a workfl