Return rowset to JSP Page
In producing a report table, for example, I'd like to have the JSP page access the
rowset from the Bean and then walk through the rowset a row at a time, formatting
output. All the examples I've found create the table code in the servlet. I'd like to
avoid that, creating the html in the JSP page only.
hi,
I think You can do it in this way.
Store the values that you get from rowset in a hash table and set the return type of your bean method to hashtable. When you call the method in jsp assign the return value to a hash table. From there you can manipulate the objects in hash table.
Hope this works,
chandu
Similar Messages
-
How to call a stored procedure to search db then return results to jsp page
Hi,
Most of what i have said is in the title. Im trying to search a database using a stored procedure that will call the procedure using sql2000 then coming back with the results to the jsp page. all of this is done using JSP web pages. if JAVA example is availabel then let me know.
I need some examples.. I cant seem to find any code that will help.
ThanksUse CallableStatement. You can set parameters with setXXX and registerOutParameter methods. And to fetch results, you can use getXXX methods of it.
-
How to call a stored to search database then return results to jsp page
Hi,
Most of what i have said is in the title. Im trying to search a database using a stored procedure that will call the procedure using sql2000 then coming back with the results to the jsp page. all of this is done using JSP web pages. if JAVA example is availabel then let me know.
I need some examples.. I cant seem to find any code that will help.
ThanksMake use of Callablestatement. You can set parameters to it by registerOutParameters and setXXX methods. And use getXXX methods to get results of procedure.
-
Why Json get function returns null in jsp page??
Hi guys,
i have developed a simple program that send HTTPrequest and get json as response. now i want to display this json to Treeview but i have able to get the valid json, i create a json object and setData(json). still its ok. but when i do json.get("id"). i get null. it is not working for any of the key present in that json object. can some one help me?? below is the code i am using.
where sb is StringBuffer containt json in text form
System.out.println(sb);
JSONObject obj = new JSONObject();
obj.setData(sb);
System.out.println(obj.getData());
System.out.println(obj.get("id"));
thanks in advance...What is the data?
-
The edit JSP page does not appear...
Hi!
I make a simple JSF application, I would like to show a DB table in a h:dataTable component and edit a given row after click, but the edit JSP page does not appear. I click the on link in the table, but the list is loaded again and not the edit page...:(
(no exception in application server console)
Please help me!
my code:
**************************************** listmydata.jsp***************************
<h:dataTable
value="#{myBean.myDataList}"
var="myDataItem"
binding="#{myBean.myDataTable}"
>
<h:column>
<f:facet name="header">
<h:outputText value="Ajdi"/>
</f:facet>
<h:commandLink action="#{myBean.editMyData}">
<h:outputText value="#{myDataItem.id}"/>
</h:commandLink>
</h:column>
********************************* MyBean.java *******************************
package bean;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import javax.faces.component.html.HtmlDataTable;
import javax.faces.context.FacesContext;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.sql.DataSource;
import wrapper.MyData;
public class MyBean {
private List myDataList;
private HtmlDataTable myDataTable;
private MyData myDataItem;
protected Connection Conn;
// *********************** actions ***********************
public String editMyData() {
myDataItem = (MyData)getMyDataTable().getRowData();
return "editmydata";
public String saveMyData() {
try {
updateDataInDB();
catch (SQLException e) {
System.out.println(e);
System.err.println(e);
e.printStackTrace();
catch (NamingException e) {
System.out.println(e);
System.err.println(e);
e.printStackTrace();
return "listmydata";
// *********************** setter ***********************
public void setMyDataList(List myDataList) {
this.myDataList = myDataList;
public void setMyDataTable(HtmlDataTable myDataTable) {
this.myDataTable = myDataTable;
public void setMyDataItem(MyData myDataItem) {
this.myDataItem = myDataItem;
// *********************** getter ***********************
public List getMyDataList() {
if (myDataList == null || FacesContext.getCurrentInstance().getRenderResponse()) {
loadMyDataList();
return myDataList;
public HtmlDataTable getMyDataTable() {
return myDataTable;
public MyData getMyDataItem() {
return myDataItem;
// *********************** others ***********************
public void loadMyDataList() {
try {
getDataFromDB();
catch (NamingException e) {
System.out.println(e);
System.err.println(e);
e.printStackTrace();
catch (SQLException e) {
System.out.println(e);
System.err.println(e);
e.printStackTrace();
void getDataFromDB() throws NamingException, SQLException {
myDataList = new ArrayList();
java.sql.PreparedStatement PreStat = ownGetConnection().prepareStatement("SELECT id, name, value FROM BEA_JSF_SAMPLE");
PreStat.execute();
java.sql.ResultSet Rs = PreStat.getResultSet();
while(Rs.next()) {
MyData OneRecord = new MyData();
OneRecord.setId(Rs.getLong(1));
OneRecord.setName(Rs.getString(2));
OneRecord.setValue(Rs.getString(3));
myDataList.add(OneRecord);
void updateDataInDB() throws SQLException, NamingException {
String sql = new String("UPDATE BEA_JSF_SAMPLE SET name=?,value=? WHERE id=?");
java.sql.PreparedStatement PreStat = ownGetConnection().prepareStatement(sql);
PreStat.setString(1,myDataItem.getName());
PreStat.setString(2,myDataItem.getValue());
PreStat.setLong(3,myDataItem.getId().longValue());
PreStat.execute();
ownGetConnection().commit();
Connection ownGetConnection() throws SQLException, NamingException {
if (Conn == null) {
InitialContext IniCtx = new InitialContext();
DataSource Ds = (DataSource)IniCtx.lookup("JDBCConnectToLocalhost_CRS");
Conn = Ds.getConnection();
return Conn;
******************************* editmydata.jsp *****************************
<%@ page language="java" contentType="text/html;charset=UTF-8"%>
<%@ taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
<%@ taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
<html>
<body>
<f:view>
<h:form>
<h:panelGrid columns="2">
<h:outputText value="Name"/>
<h:inputText id="name" value="#{myBean.myDataItem.name}"/>
<h:outputText value="Value"/>
<h:inputText id="value" value="#{myBean.myDataItem.value}"/>
</h:panelGrid>
<h:commandButton action="#{myBean.saveMyData}" value="Save"/>
</h:form>
</f:view>
</body>
</html>I have put his lines in the faces-config.xml and now it works:
<navigation-rule>
<from-view-id>*</from-view-id>
<navigation-case>
<from-outcome>editmydata</from-outcome>
<to-view-id>editmydata.jsp</to-view-id>
</navigation-case>
</navigation-rule>
<navigation-rule>
<from-view-id>*</from-view-id>
<navigation-case>
<from-outcome>listmydata</from-outcome>
<to-view-id>listmydata.jsp</to-view-id>
</navigation-case>
</navigation-rule>
I don't understand, that I define the next JSP page in the bean java file, which must be shown, but I must define this in the faces-config.xml as well.
for example:
public String editMyData() {
myDataItem = (MyData)getMyDataTable().getRowData();
return "editmydata";
is it right or Do I make a mistake somewhere? -
Hi all,
I am using return statement in JSP page after a redirect to stop executing that page. If the data bean is not present then it must go to previous page. When this return statement is executed the previous page is displayed but url in browser remains same. Why it is so ?. Is there any other way to tell a JSP page to stop executing and redirect to another page.
rgds
Antony PaulHi Antony,
do you use the "forward()" method or the "redirect()" method???
rgds
Howy -
Passing parameters from a Java class to Jsp page
Hi everybody. I'm newbie in using Java class in conjunction with JSP pages. Infact I have a problem. How can I pass the parameters used in a Java class (as UserName, Password, and so on..) to a JSP page? What methods (and classes) I have to use?
Thank you in advance
Have a nice dayIt still doesn't work. I write the code
//my java class
package channel_service;
import java.util.Vector;
* <p>Title: </p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2002</p>
* <p>Company: </p>
* @author unascribed
* @version 1.0
public class CallMenu {
private Vector parameters = new Vector();
public void setParameters( String UserId ) {
parameters.add(0, UserId);
//parameters.add(2, Pin);
//parameters.add(3, UserName);
//parameters.add(4, Greeting);
public Vector getParameters() {
return parameters;
//my jsp page
<%@ page import="Channel_Service.src.channel_service.CallMenu" %>
<%@ page import="java.util.Vector" %>
<html>
<head><title>User Menu Page</title></head>
<body>
<center><h1><i><b>This is your personal User Menu page</b></i></h1></center>
<br>
<br>
<center><h2><i>In the list below you'll find all your personal information (as UserID, Password and so on...)
and all the function you have the rights to use</i></h2></center>
<br>
<br>
<table align=center>
<tr>
<%
CallMenu cl = new CallMenu();
cl.setParameters();
Vector params = cl.getParameters();
String UserId = (String)params.elementAt(0);
String Pin = (String)params.elementAt(1);
String UserName = (String)params.elementAt(2);
String Greeting = (String)params.elementAt(3);
%>
<td><h2><b><i>User ID = <%= UserId %></td></tr>
<tr><td><h2><b><i>PIN = <%= Pin %></td></tr>
<tr><td><h2><b><i>User Name = <%= UserName %></td></tr>
<tr><td><h2><b><i>The system says <%= Greeting %></td></tr>
</table>
</body> -
How to use value returned from a bean in jsp page
Hi All,
I have a string array value being returned from a javabean to a jsp page. I want to be able to assign the value to a variable in the jsp page.
How do I do this?
Many thanks :)thanks for your response.
I actually used something like this:
<% String loggedin = log.User(user,password);
out.println(loggedin);
%>i am not yet as much of an expert on beans as i would like to be, but i thought it is not really a bean if it has a getter method which takes arguments? -
How to return javascript function value to jsp page
Hi i want to retrieve values from javascript function to jsp page, how can i do that ? i am trying this but its not working
<script language="javascript" type="text/javascript" src="/feedback/common/scripts/config.js"></script>
<script language="javascript" type="text/javascript" src="/feedback/common/scripts/richtext.js"></script>
<td>
<jsp:param id="description" value= "<%=request.initRTE('', '')%>"/>
</td>
here this initRTE function is used for displaying rich text editor .....i want to retrieve back the contetnt written in this editor and save it to DB.
Please help.
Edited by: xtech on Apr 4, 2008 12:00 PMsurely i will do that but my app is still not working.....
here is my code
</td>
<td align="left">
<script language="javascript" type="text/javascript" src="/feedback/common/scripts/config.js"></script>
<script language="javascript" type="text/javascript" src="/feedback/common/scripts/richtext.js"></script>
<h:inputHidden id="introtext" value= "<%=request.getParameterValues(description)%>">
<script>
initRTE('','');
</script>
</td>
in java script function i am geeting the text content
function initRTE(rtePreloadContent, rteCSS) {
rtePreloadContent=document.getElementById('surveyinfo:introtext').value;
startRTE(rtePreloadContent);
menuBuilder();
var description= document.getElementById(rteFormName).value;
return description;
basically i want to get the text written in text editor in jsp and want to send it to DB.(Here initRTE() function is calling rich text editor)
i have downloaded this editor from this url
http://freerichtexteditor.com/page/4.htm
and trying to embed it in my app. -
Capturing xml data returned from a url post in a jsp page
Hi,
We are writing a interface which will capture data returned from an other website. The data returned will be in XML form.
http://www.ecrm.staging.twii.net/ecrmfeed/ecrmfeedservices.sps?eCRMFeedInputXml=<twii><ecrmfeedinput><data%20method="Login"><username>[email protected]</username><password>password</password></data></ecrmfeedinput></twii>
When the above url is executed in a browser, it required NT authentication. The username and password is getcouponed. Once the username and password is fed, we can see the output in the form of a xml. We require the xml in a String variable in a jsp page. We need to know the steps on how to execute the url in a jsp page. We used the url object to do the same, but we get a error saying "java.net.UnknownHostException: www.ecrm.staging.twii.net".
Can anyone help?
Regards,
Gopinath.Hi,
I would like to know if I can use the java.net package to get anything out of a website which requires authentication. In this case NT authentication.
Thanks in advance,
Gopinath. -
Capturing LOV Return Item in a field of JSP Page
Dear Members,4
I am using JDev 10g (10.1.3.5.0)
Requirement: I want to display a LOV for a field which is not bound to data model. To achieve this requirement I have follwed the below steps.
Steps:-
I have a simple JSP page in which there is a select input text field which is as follows:-
*<af:selectInputText label="Label 1" action="dialog:Test1" windowHeight="500" windowWidth="400"*
id="label1"/>
I have created the necessary navigation rules to Test1 page and also the required VO for the respective LOV.
From this Label 1 field I am able to go to the Test1 page which is a LOV Page and I am displaying the LOV records. After selecting a record, I want to come back to my main JSP Page and the selected value should appear in the field Label 1. I am not able to return the selected LOV value to the Label 1._
The code I am using to return the value from the LOV Page is as follows:-
public void returnObject(ActionEvent actionEvent)
JUCtrlValueBindingRef selectedRowData = (JUCtrlValueBindingRef)getTable1().getSelectedRowData();
if(selectedRowData==null)
AdfFacesContext.getCurrentInstance().returnFromDialog(null, null);
return ;
assetCat = (String)selectedRowData.getRow().getAttribute("Name");
AdfFacesContext.getCurrentInstance().returnFromDialog(this,null);
Note: I want to return the assetCat value to the Label 1 field.
Can any one please help me in resolving this issue.
Many thanks in advance.
Reards,
R4SHello,
Many thanks for your reply.
I am new to ADF. Can you please elaborate your solution.
Regards,
R4S -
How can i hand the RowSet to the next jsp page
In a jsp page, I get a RowSet as the following:
<input type="hidden" name="result" value="<%=ds.getRowSet()%>">
I want to handle with this RowSet in the next jsp page, so
I do in the next jsp page as the following:
<% RowSet rowset = (RowSet)request.getAttribute("result"); %>
But I was told null error. How can i hand the RowSet to the next jsp page.Help. Thanks a lot!Hello Charles,
I did the registration in the same way as in the JDeveloper 3.2.3 (see follows)
// make sure the application is registered
oracle.jbo.html.jsp.JSPApplicationRegistry.registerApplicationFromPropertyFile(session , "ReefBC_BCPackage_BCPackageModule");
The argument ReefBC_BCPackage_BCPackageModule is a property file (ReefBC_BCPackage_BCPackageModule.properties). After some tries, I can still use it in JDeveloper 9i R2. The reason to keep it is that there would be a lot of migration work of javabean calling if I change it to <job:DataWebBean..>. But I am wondering, do I initialize two application modules when I use registerApplicationFromPropertyFile() and <jbo:ApplicationModule..> in the same page.
The problem in doStartTag() is found after I post "http://forums.oracle.com/forums/thread.jsp?forum=83&thread=155210&tstart=75&trange=15", by tracing into the <jbo:ApplicationModule..> after calling the OrdHttpUploadFormData. HtmlServices.getRequestParameters sends back an exception, that breaks the running of the program. It was temperorily solved by extending the ApplicationModuleTag. If <jbo:..> could use the application module initialized by registerApplicationFromPropertyFile(), I guess it may be a better workaround.
Long postings are being truncated to ~1 kB at this time. -
In JSP pages request.getParameter returns null
There are two jsp's,the first JSP has 1 textbox inside the form tag.We input the values in the textbox and submit.
Code :Ist jsp
<BODY>
<HEAD>
function validate()
document.add.submit();
</HEAD>
<FORM name="add" method="post" action=/dir/two.jsp" >
<TABLE width="37%" border="0" align="center" class="c4f3">
<TR>
<TD class="c4">Rating</TD>
<TD><input type=text name="rating"></TD?
</TR>
<TR>
<TD align=center><INPUT type="button" name="submitadd" value="Submit" onClick="validate()" </TD>
</TR>
</TABLE>
</FORM>
</BODY>
After the submit it goes to the 2nd JSP page .
code:2nd Jsp
<%
String Rating=request.getParameter("rating");
out.println(" Rating "+Rating);
%>
The 2nd JSP pages gets the values by request.getParameter.When I use method='post' in Ist JSP ,even if I enter values in the textbox, it prints null. But when I give method="get" , it prints the value.
Pls let me know if there is any problem in the code or its the problem due to webserver configuration.Also suggest the solution to over come this problem.
ThanksIf I'am right you have misplaced the opening body-tag of your first jsp-page.
The opening body-tag should follow after the closing head tag .
The structure of your HTML-code should look like this:
<html>
<head>
</head>
<body>
</body>
</html> -
Returning data in a jsp page.
Hello all! :-D
i need to build a simple web app, that retrieves data from an array list. Well my sequence is as follows:
1-JSP request:
2- Servlet:
3-Java Class
4-Back to the servlet
5- Show result in a table inside a jsp page.
How do i send the array list object into a jsp page so it shows the data in the table?
Thanks in advance!hi,
servlet - you may use HttpSession:
example:
ArrayList list = new ArrayList();
list.add("data1");
list.add('data2");
session.setAttribute("lists", list);{code}
JSP:
{code}<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
<c:forEach var="list" items="lists">
${list}
</c:forEach>{code}
I hope this could help
quince -
Returning Values to a JSP Page
I have a servlet that recives data from a form using POST. Once I've processed the data I need to pass my new data (and some of the original data) to a new JSP page.
This was originally done using response.sendRedirect with all the data held within a parameter string.
We've now been told that we've not to pass any data via URL's, Is there a way to secruley pass data back to a jsp page.
I thought about using:-
protected void transferToRD(String target, HttpServlet servlet, HttpServletRequest req, HttpServletResponse res)
try
RequestDispatcher rd = servlet.getServletContext().getRequestDispatcher(target);
rd.forward(req, res);
catch (Exception exc)
exc.printStackTrace();
But I don;t have a servlet to pass in as a parameter
Any help would be appreciatedOr you can use one of these in the JSP page:
<jsp:usebean id="var_name" class="class_name" scope="request">Only thing to remember is that if it can't find the variable name then it will call the default constructor to create a new instance, and if that doesn't exist then you will get a runtime error in your JSP page which looks pretty ugly.
Maybe you are looking for
-
my ipad will no longer connect to the laptop. it comes up with usb not recognized. also when trying to connect to the power the first time i connect, nothing, but when i unplug from ipad and plug in a second time it charges
-
Hi, im tryin to sent idoc from one sap server to another what i should do in partner profiles and port definition and rfc destination what should be the partner number in partner profiles i have created idoc type and segment type after can anyone tel
-
I get this message even when I have nothing open. When it happens I restart as instructed and everything is okay for awhile and then it starts again.
-
Data discrepancy between Webi Report and same Query fired on SQL Server 2k5
Hi , We are facing an issue in BO XI R2. We need to run a Webi report in which negative values for forecasting data for year 2011 and 2012 should be displayed. When we are running this report for negative values, we are getting message u2018There is
-
Degraded Text Image Quality with Reader 9
I upgraded to Adobe Reader 9, which I use to open an online daily publication. However, with Reader 9, print quality of this publication (an online newspaper) is now severely degraded, to the point where I have to enlarge the image to about 400% in o