trying to call a data bean from jsp - Weblogic
This is a discussion on trying to call a data bean from jsp - Weblogic ; I get the following error:
C:\bea\user_projects\infologic1\.\myserver\.wlnotd elete\extract\myserver_BibleApp_BibleApp\jsp_servl et\__menu.java:146:
cannot resolve symbol
probably occurred due to an error in /menu.jsp line 27:
Enumeration.categoryIds = categories.keys();
code:
menu.jsp
----------
String base = (String) application.getAttribute("base");
%>
category
Hashtable categories = DbBean.getCategories();
Enumeration.categoryIds = ...
-
trying to call a data bean from jsp
I get the following error:
C:\bea\user_projects\infologic1\.\myserver\.wlnotd elete\extract\myserver_BibleApp_BibleApp\jsp_servl et\__menu.java:146:
cannot resolve symbol
probably occurred due to an error in /menu.jsp line 27:
Enumeration.categoryIds = categories.keys();
code:
menu.jsp
----------
<%@page import="java.util.*"%>
<%
String base = (String) application.getAttribute("base");
%>
|
category |
|
<%
Hashtable categories = DbBean.getCategories();
Enumeration.categoryIds = categories.keys();
while (categoryIds.hasMoreElements()) {
Object categoryId = categoryIds.nextElement();
out.println("
+ categoryId.toString() + ">" + categories.get(categoryId) + "
");
}
%>
-------------------------------------------------------------------------------------
web.xml
"http://java.sun.com/dtd/web-app_2_3.dtd">
ControllerServlet
ControllerServlet
base
http://localhost:7001/BibleApp/
imageURL
http://localhost:7001/BibleApp/
dbURL
jdbc:weblogic:mssqlserver4:users@COMPAQSERVER
usernameDbConn
dinesh
passwordDbConn
passs
-----------------------------------------------------------------------
DbBean.class
package showMeItNow;
import java.util.*;
import java.sql.*;
import showMeItNow.Poll;
public class DbBean {
public String dbUrl="";
public String dbUserName="";
public String dbPassword="";
public void setDbUrl(String url) {
dbUrl=url;
}
public void setDbUserName(String userName) {
dbUserName=userName;
}
public void setDbPassword(String password) {
dbPassword=password;
}
public Hashtable getCategories() {
Hashtable categories = new Hashtable();
try
{
Connection connection = DriverManager.getConnection(dbUrl, dbUserName,
dbPassword);
CallableStatement cstmt = connection.prepareCall("{? = call dbo.categoryListing()}");
//register the stored procedure's output paramater!!!
cstmt.registerOutParameter(1, java.sql.Types.VARCHAR);
cstmt.registerOutParameter(2, java.sql.Types.VARCHAR);
ResultSet rs = cstmt.executeQuery();
while (rs.next()) {
categories.put(rs.getString(1), rs.getString(2) );
}
rs.close();
cstmt.close();
connection.close();
}
catch (SQLException e) { }
return categories;
}
}
-
Re: trying to call a data bean from jsp
You might want to look at whether there is any data being fetched from
the DB. Use some System.out.println()'s in the code where you fetch the
data from the stored proc.
Another way might be to comment out the database code, add some dummy
values into the hastable and make sure that the page comes up as you
expect.. and then go ahead with the database thingy..
--
Nagesh
dinesh wrote:
> Thanks, the page is loading up. But, it is just blank. It is not displaying the
> hastable data. Any ideas?
>
> thanks again,
> Dinesh
>
> Nagesh Susarla wrote:
>
>>>Enumeration.categoryIds = categories.keys();
>>
>>try replacing the dot '.' with a space and it should be all fine ..
>>maybe a typo.
>>
>>Enumeration categoryIds = categories.keys();
>>
>>--
>>Nagesh
>>
>>
>>dinesh prasad wrote:
>>
>>>I get the following error:
>>>
>>>C:\bea\user_projects\infologic1\.\myserver\.wlnotd elete\extract\myserver_BibleApp_BibleApp\jsp_servl et\__menu.java:146:
>>>cannot resolve symbol
>>>probably occurred due to an error in /menu.jsp line 27:
>>>Enumeration.categoryIds = categories.keys();
>>>
>>>
>>>code:
>>>
>>>menu.jsp
>>>----------
>>><%@page import="java.util.*"%>
>>>
>>>
>>><%
>>> String base = (String) application.getAttribute("base");
>>> %>
>>>
>>>
>>>
>>>
>>>
>>>
>>> |
>>>
>>>
>>>category |
>>>
>>>
>>>|
>>>
>>> <%
>>> Hashtable categories = DbBean.getCategories();
>>> Enumeration.categoryIds = categories.keys();
>>> while (categoryIds.hasMoreElements()) {
>>> Object categoryId = categoryIds.nextElement();
>>> out.println("
>>>+ categoryId.toString() + ">" + categories.get(categoryId) + "
");
>>>}
>>>
>>> %>
>>>-------------------------------------------------------------------------------------
>>>
>>>web.xml
>>>
>>
>>>"http://java.sun.com/dtd/web-app_2_3.dtd">
>>>
>>>
>>>
>>> ControllerServlet
>>> ControllerServlet
>>>
>>>
>>> base
>>> http://localhost:7001/BibleApp/
>>>
>>>
>>>
>>> imageURL
>>> http://localhost:7001/BibleApp/
>>>
>>>
>>> dbURL
>>> jdbc:weblogic:mssqlserver4:users@COMPAQSERVER
>>
>>>
>>>
>>> usernameDbConn
>>> dinesh
>>>
>>>
>>> passwordDbConn
>>> passs
>>>
>>>
>>>
>>>
>>>
>>>-----------------------------------------------------------------------
>>>DbBean.class
>>>
>>>package showMeItNow;
>>>
>>>import java.util.*;
>>>import java.sql.*;
>>>import showMeItNow.Poll;
>>>
>>>public class DbBean {
>>> public String dbUrl="";
>>> public String dbUserName="";
>>> public String dbPassword="";
>>>
>>> public void setDbUrl(String url) {
>>> dbUrl=url;
>>> }
>>>
>>> public void setDbUserName(String userName) {
>>> dbUserName=userName;
>>> }
>>>
>>> public void setDbPassword(String password) {
>>> dbPassword=password;
>>> }
>>>
>>> public Hashtable getCategories() {
>>> Hashtable categories = new Hashtable();
>>> try
>>> {
>>> Connection connection = DriverManager.getConnection(dbUrl,
>>
>>dbUserName,
>>
>>>dbPassword);
>>>
>>> CallableStatement cstmt = connection.prepareCall("{?
>>
>>= call dbo.categoryListing()}");
>>
>>> //register the stored procedure's output paramater!!!
>>> cstmt.registerOutParameter(1, java.sql.Types.VARCHAR);
>>> cstmt.registerOutParameter(2, java.sql.Types.VARCHAR);
>>> ResultSet rs = cstmt.executeQuery();
>>> while (rs.next()) {
>>> categories.put(rs.getString(1), rs.getString(2) );
>>> }
>>> rs.close();
>>> cstmt.close();
>>> connection.close();
>>> }
>>> catch (SQLException e) { }
>>> return categories;
>>> }
>>>
>>>}
>>>
>>>
>>>
>>
>
|