How to retrieve data and display in JSP page
hi,
i am trying to retrieve data from SQL server 2000 and display in JSP Page. I have already place the codes of the retrieve in the bean file. I wanna ask is that how to display in the JSP page. If possible, can provide example codings for mi to reference?
Thanks
Regards,
shixuan
HI Tan ,
I pressume that you wanted to make use of PDK, the code can go like this .
<b><u>1) JAVA file</u></b>
import com.sapportals.htmlb.DropdownListBox;
import com.sapportals.htmlb.InputField;
import com.sapportals.htmlb.event.Event;
import com.sapportals.htmlb.page.DynPage;
import com.sapportals.htmlb.page.PageException;
import com.sapportals.portal.htmlb.page.JSPDynPage;
import com.sapportals.portal.htmlb.page.PageProcessorComponent;
import com.sapportals.portal.prt.component.IPortalComponentRequest;
import com.sapportals.portal.prt.component.IPortalComponentSession;
import com.sapportals.portal.prt.component.IPortalComponentContext;
import java.sql.*;
public class P_SAP_B_User extends PageProcessorComponent
* Method : getPage()
* Description :
* Input Parameters : None
* Returns : Object of Class DynPage
public DynPage getPage()
return new P_SAP_B_UserDynPage();
} // end of dynPage()
public static class P_SAP_B_UserDynPage extends JSPDynPage
/* Variable Declaration */
/* Object of bean class P_SAP_B_CreateUser initialised to null */
private P_SAP_B_CreateUser createUserBean = null;
/* Flags for checking the occurance of Event & Error. */
private int iFlag=0;
private int iErrFlag=0;
/* Variables for storing the information
entered by user in each text field */
private String sFname;
private String sSname;
private String sAge;
private String sExp;
private String sSkill;
private String sUnit;
* Method : doInitialization()
* Description :
* Input Parameters : None
* Returns : None
public void doInitialization()
IPortalComponentSession componentSession = ((IPortalComponentRequest)getRequest()).getComponentSession();
Object o = componentSession.getValue("createUserBean");
if(o==null || !(o instanceof P_SAP_B_CreateUser))
createUserBean = new P_SAP_B_CreateUser();
componentSession.putValue("createUserBean",createUserBean);
} // end of if
else
createUserBean = (P_SAP_B_CreateUser) o;
} // end of else
}//end of doInitialisation()
* Method : onUpdate()
* Description :
* Input Parameters : object of Event class
* Returns : None
public void onUpdate(Event e)throws PageException
/* sets flag to 1 when update button is clicked. */
iFlag=1;
* Method : doProcessAfterInput()
* Description :
* Input Parameters : None
* Returns : None
public void doProcessAfterInput() throws PageException
InputField ifFirstName = (InputField) getComponentByName("FirstName");
InputField ifSecondName = (InputField) getComponentByName("SecondName");
InputField ifAge = (InputField) getComponentByName("Age");
InputField ifExp = (InputField) getComponentByName("Exp");
InputField ifSkill = (InputField) getComponentByName("Skill");
DropdownListBox dlbUnit = (DropdownListBox) getComponentByName("Unit");
int iAge,iExp;
IPortalComponentRequest request = (IPortalComponentRequest) this.getRequest();
IPortalComponentContext myContext = request.getComponentContext();
P_SAP_B_CreateUser myNameContainer = (P_SAP_B_CreateUser) myContext.getValue("createUserBean");
if(ifFirstName != null)
this.sFname = ifFirstName.getValueAsDataType().toString() ;
} // end of if
if(ifSecondName!= null)
this.sSname = ifSecondName.getValueAsDataType().toString() ;
} // end of if
if(ifAge!= null)
this.sAge = ifAge.getValueAsDataType().toString() ;
} // end of if
if(ifExp!= null)
this.sExp = ifExp.getValueAsDataType().toString() ;
} // end of if
if(ifSkill != null)
this.sSkill = ifSkill.getValueAsDataType().toString() ;
} // end of if
if(dlbUnit != null)
this.sUnit = dlbUnit.getSelection().toString() ; ;
} // end of if
/* Data Validation */
/* try block for numeric Exception */
try
/* checking for any field left blank by the user */
if(sFname.equals("") || sSname.equals("") || sAge.equals("")|| sExp.equals("") || sSkill.equals(""))
/* set error flag to 1 in case of any field left blank */
iErrFlag=1;
} // end of if
else
/* converting Age and Experience fields (String) to integer */
iAge= Integer.parseInt(sAge);
iExp= Integer.parseInt(sExp);
/* setting the boundaries on the value in Age Field */
if(iAge<0)
/* set error flag to 2 in case of age below 0 */
iErrFlag=2;
}// end of if
/* setting the boundaries on the value in Experience field */
else if(iExp<0 ||(iExp/12)>=iAge)
/* set error flag to 3 in case of experience below 0 or exceeding the age in years */
iErrFlag=3;
}// end of else if
/* In case of no error */
else
/* setting the bean variables */
try
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection("jdbc:odbc:Test");
String query="insert into UserData values(?,?,?,?,?,?)";
PreparedStatement prestat=con.prepareStatement(query);
/* setting the values to be inserted into the user table */
prestat.setString(1,sFname);
prestat.setString(2,sSname);
prestat.setString(3,sAge);
prestat.setString(4,sExp);
prestat.setString(5,sSkill );
prestat.setString(6,sUnit);
prestat.executeUpdate() ;
prestat.close();
con.close();
myNameContainer.setSFname(sFname);
myNameContainer.setSLname(sSname);
myNameContainer.setSAge(sAge);
myNameContainer.setSExp(sExp);
myNameContainer.setSSkill(sSkill);
myNameContainer.setSUnit(sUnit);
} // end of inner try block
catch(Exception sqle)
myNameContainer.setErrMessage("Update failed ! Please try again." );
} // end of catch corresponding to inner try
} // end of inner else
} //end of outer else
} //end of outer try block
catch(Exception e)
/* setting flag to 4 in case of non-numeric age/experience values */
iErrFlag = 4;
/* Displaying error message corresponding to the value of error flag */
switch(iErrFlag)
/* Empty Field */
case 1:myNameContainer.setErrMessage( "Please Fill all the fields");
break;
/* Invalid Value in the age field */
case 2:myNameContainer.setErrMessage( "Enter a valid value in Age field.(Hint : Have you entered Age<0 ?");
break;
/* Invalid Value in the experience field */
case 3:myNameContainer.setErrMessage( "Enter a valid value in Experience field.(Hint : Experince should not be negative or greater than your age in months)");
break;
/* Non-numeric value in the Age/ experience fields */
case 4:myNameContainer.setErrMessage( "Please Enter Numeric Value for Age and Experience");
break;
} // end of switch-case block
} //end of doProcessAfterInput()
* Method : doProcessBeforeOutput()
* Description :
* Input Parameters : None
* Returns : None
public void doProcessBeforeOutput() throws PageException
/* Displays Form for new user creation by default */
this.setJspName("P_SAP_B_UserCreationForm.jsp");
/* In case of an error display an error message page */
if(iErrFlag!=0)
setJspName("ErrorPage.jsp");
} //end of if
/* Displays the user's information as entered in the SQL
database after its been uploaded by the user */
else if(iFlag==1)
setJspName("hello.jsp");
} // end of else if
} // end of doProcessBeforeOutput()
} // end of P_SAP_B_UserDynPage Class
} // end of P_SAP_B_User class
* End of File P_SAP_B_User.java
2) Bean
package com.sap.usercreation;
import java.io.Serializable;
public class P_SAP_B_CreateUser implements Serializable
private String sFname;
private String sLname;
private String sUnit;
private String sSkill;
private String sExp;
private String sAge;
private String errMessage;
* @return
public String getSFname() {
return sFname;
* @return
public String getSLname() {
return sLname;
* @param i
* @param string
public void setSFname(String string) {
sFname = string;
* @param string
public void setSLname(String string) {
sLname = string;
* @return
public String getSUnit() {
return sUnit;
* @param string
public void setSUnit(String string) {
sUnit = string;
* @return
public String getSSkill() {
return sSkill;
public void setSSkill(String string) {
sSkill = string;
* @return
public String getSAge() {
return sAge;
* @return
public String getSExp() {
return sExp;
* @param string
public void setSAge(String string) {
sAge = string;
* @param string
public void setSExp(String string) {
sExp = string;
* @return
public String getErrMessage() {
return errMessage;
* @param string
public void setErrMessage(String string) {
errMessage = string;
3) The Jsp file i have already posted.
See if you copy this code and paste it wont work as i have not given you full code ,But yes this gives you an overview of how things can be done .
Thanx
Pankaj
Similar Messages
-
How to filter datas and display in java
Hi guys.
I'm kind of new to Java,
I've have a database where values are stored ,i just have to take one column and i got to filter one value and display all .
is there a command to filter
I just want to do that if that Not wanted value is there to ignore and display the rest of the data in the html when search is called.
i have to do this in the java , not in jsp.
mysql,hibernate,ejb,jsp are being used at my environment.
please helpSimply put you want to 'selectively' navigate through the collection of data. Here, is an alternative using Iterator pattern given below;
Create an interface
* Iterator interface has method declarations for iterating through
* data.
public interface Iterator {
public MyData next(int current);
public MyData prev(int current);
}// End of interfaceNow, create implementation classes for the above interface and you can aptly name them based upon your filtering criteria
public MyFlter implements Iterator {
* next � method which takes the current data number
* and returns the next selected data.
public MyData next (int current) {
MyData data = null;
while desired data not found: iterate --> implement your selection criteria here
return data
} Similarly implement the previous method.
Hope that helps. -
Retrieve data and display using struts
hello..
pls help...
i know how to insert data into the data base using struts. but i don't know how to retrieve it. i have been trying to retrieve it using resultset .. but not sure how to display it using struts properly..
pls help...hi :-)
1. put your resultset in a list.
2. put that list in a request.
3. show the contents of list using jstl.
regards, -
Database connection and display in JSP page
hi,
I am new to SAP netweaver. I have created a project using JSPDynPage, Beans and java file. I have configure the datasouce in Visual Composer. I deploy the project on the portal itself. I have try all kinds of codes bt cannot retrieve. Is there anyone can give a same codes for mi to connect to the datasource in Visual Composer and able to retrieve data, insert data and update data in SQL Server 2000. Thanks
Regards,
shixuanHai Shixuan,
Refer this link. I will helps
Access data from SqlServer through Visual Composer.....?
http://help.sap.com/saphelp_nw2004s/helpdata/en/fe/68e343cc68414da4426258d3e896ae/content.htm
Write this code wher you need in JSPDynPage
And
MSSQL DataBase Access -> Help me
Thanks and Regards
Venkatesh
Message was edited by:
Venkatesh Ranganathan
Message was edited by:
Venkatesh Ranganathan -
Read a property file value and display in jsp page
I need a solution for the below mentioned scenario,
I want to read a value from the property file in JSP page.
For Example, Let us have a property file called A.properties, in the file, we have a value, username = Sam.
I want to bring this value in the jsp page.
Please assist in this issue.
thanks in advance.If you are using struts, then you have to first load the taglib like
<%@ taglib uri="/WEB-INF/strutsresources/struts-bean.tld" prefix="bean" %>and then access the particular property like
<bean:message key="welcome"/>Also, you have to define <message-resources> in struts-config. Though I am not into struts for year now, So, please confirm the code. -
To retrieve data and display using tcode
Respected Gurus,
Can anybody guide me for the scenario:
1) to develop the ztable ,the entries/fields in ztable are some user built and some taken frm SAP standard tables(Mseg,Makt,Lfa1 or more).
2) i have to fill the table using tcode.
3) also to display the data on single click of Ok_code on the screen .
4) kindly guide me for the all code for the same scenario.
regards,Hi,
It is very much possible.
1. You can create a new table in SE11/SE12 and u can create this table as a maintainable table( able to maintain entries). An ABAPer can help you to enable this table as maintainable one.
2. If you know the name of the maintainable table, you can maintain entries directly in SM30. If you need a tcode for this, you can also do this by creating a tcode in SE91 for the table.
3. If you know the tcode, you can directly view and download the entries using the tcode itself. -
How to retrieve data (xml file) using jsp
I am a newbie to xml. I have decided to store my information in the xml file. may I know how can I retrieve my information from the xml file?
Thanx in advance.I am a newbie to xml. I have decided to store my
information in the xml file. may I know how can I
retrieve my information from the xml file?
Thanx in advance.You can get the information from the XML file using one of the parsers available, such as Xerces http://xml.apache.org, and JDOM as an API.
Using this you have the option of having a SAXParser or a DOMParser.
SAX (Simple API for XML) is an event based parser, so if you know the XML structure, and need to find a certain element, you can just look for the element name,and retrieve the value of the element, it's attributes and its children.
DOM(Document Object Model)represents the XML as a tree, but uses more resources as it stores the entire tree in memory. But it is good in that you can traverse the whole tree.
JDOM would be a good idea too. If you download this, you can use it's API, which is very good, that will use the parser on your system (Xerces). I would definately recommend JDOM. -
How to filter data and display
hi there
i have a product page and ploduct list menue. i want to be
able to filter products.
for example on my list i have shose. and they come in
diffrent sizes.
when cutomers selects size 10 from down down list databse
lists all shose size 10. how can i get mysql to show all products
when customer selects show all products from drow down list?
SELECT *
FROM shoetable
WHERE shoesize = colname
what value should i pass to mysql to show all products.
if colname = 9 it works fine lists all products with size 9.You could do something like this with the SQL:
if(!isset($_POST['size'])){
$query_rsShoes = "SELECT * FROM shoetable";
else {
$query_rsShoes = "SELECT * FROM shoetable WHERE shoesize =
$_POST['size'] . "'";
Ken Ford
Adobe Community Expert - Dreamweaver
Fordwebs, LLC
http://www.fordwebs.com
"elyas2004" <[email protected]> wrote in
message
news:fqaq2c$t25$[email protected]..
> hi there
>
> i have a product page and ploduct list menue. i want to
be able to filter
> products.
>
> for example on my list i have shose. and they come in
diffrent sizes.
>
> when cutomers selects size 10 from down down list
databse lists all shose
> size 10. how can i get mysql to show all products when
customer selects
> show
> all products from drow down list?
>
> SELECT *
> FROM shoetable
> WHERE shoesize = colname
>
>
> what value should i pass to mysql to show all products.
>
> if colname = 9 it works fine lists all products with
size 9.
>
>
> -
How to display date and time on jsf page
Hi,
how to display date and time on jsf page
we are using 11.2.0.0 jdeveloper on windows.
thanks
Edited by: user12187801 on 26-Jul-2012 01:42Your question is certainly lacking some information.
If you want a constantly updating date/time - then JavaScript is your best bet, and Google would find you examples like [url http://www.webestools.com/scripts_tutorials-code-source-7-display-date-and-time-in-javascript-real-time-clock-javascript-date-time.html]this
If you meant something else, then it's back to you to explain. -
How to retrieve data from catsdb table and convert into xml using BAPI
How to retrieve data from catsdb table and convert into xml using BAPI
Points will be rewarded,
Thank you,
Regards,
Jagrut BharatKumar ShuklaHi,
This is not your requirment but u can try this :
CREATE OR REPLACE DIRECTORY text_file AS 'D:\TEXT_FILE\';
GRANT READ ON DIRECTORY text_file TO fah;
GRANT WRITE ON DIRECTORY text_file TO fah;
DROP TABLE load_a;
CREATE TABLE load_a
(a1 varchar2(20),
a2 varchar2(200))
ORGANIZATION EXTERNAL
(TYPE ORACLE_LOADER
DEFAULT DIRECTORY text_file
ACCESS PARAMETERS
(FIELDS TERMINATED BY ','
LOCATION ('data.txt')
select * from load_a;
CREATE TABLE A AS select * from load_a;
SELECT * FROM A
Regards
Faheem Latif -
How to retrieve start and end date values from sharepoint 2013
Hi,
How to retrieve start and end date values from new event form of calendar in SharePoint foundation2013
Thanks
Gowri BalaguruHi Srini
Yes i need to have parallel flow for both and in the cube where my reporting will be on monthly basis i need to read these 2 master data and get the required attributes ( considering last/first day of that month as per the requirement).......but i am just wondering this is common scenario....while there are so many threads written for populating 0employee from 0person......don't they have such requirement.....
Thanks
Tripple k -
How to Read the one Source Column data and Display the Results
Hi All,
I have one PR_ProjectType Column in my Mastertable,Based on that Column we need to reed the column data and Display the Results
Ex:
Pr_ProjectType
AD,AM
AD
AM
AD,AM,TS,CS.OT,TS
AD,AM
like that data will come now we need 1. Ad,AM then same we need 2. AD also same we need 3. AM also we need
4.AD,AM,TS,CS.OT,TS in this string we need AD,AM only.
this logic we need we have thousand of data in the table.Please help this is urgent issue
vasuHi Vasu,
Based on your description, you want to eliminate the substrings (eliminated by comma) that are not AD or AM in each value of the column. Personally, I don’t think this can be done by just using an expression in the Derived Column. To achieve your goal, here
are two approaches for your reference:
Method 1: On the query level. Replace the target substrings with different integer characters, and create a function to eliminate non-numeric characters, then replace the integer characters with the corresponding substrings. The statements
for the custom function is as follows:
CREATE FUNCTION dbo.udf_GetNumeric
(@strAlphaNumeric VARCHAR(256))
RETURNS VARCHAR(256)
AS
BEGIN
DECLARE @intAlpha INT
SET @intAlpha = PATINDEX('%[^0-9]%', @strAlphaNumeric)
BEGIN
WHILE @intAlpha > 0
BEGIN
SET @strAlphaNumeric = STUFF(@strAlphaNumeric, @intAlpha, 1, '' )
SET @intAlpha = PATINDEX('%[^0-9]%', @strAlphaNumeric )
END
END
RETURN ISNULL(@strAlphaNumeric,0)
END
GO
The SQL commands used in the OLE DB Source is like:
SELECT
ID, REPLACE(REPLACE(REPLACE(REPLACE(dbo.udf_GetNumeric(REPLACE(REPLACE(REPLACE(REPLACE([ProjectType],'AD,',1),'AM,',2),'AD',3),'AM',4)),4,'AM'),3,'AD'),2,'AM,'),1,'AD,')
FROM MyTable
Method 2: Using a Script Component. Add a Derived Column Transform to replace the target substrings as method 1, use Regex in script to remove all non-numeric characters from the string, add another Derived Column to replace the integer
characters to the corresponding substring. The script is as follows:
using System.Text.RegularExpressions;
Row.OutProjectType= Regex.Replace(Row.ProjectType, "[^.0-9]", "");
References:
http://blog.sqlauthority.com/2008/10/14/sql-server-get-numeric-value-from-alpha-numeric-string-udf-for-get-numeric-numbers-only/
http://labs.kaliko.com/2009/09/c-remove-all-non-numeric-characters.html
Regards,
Mike Yin
TechNet Community Support -
How to Retrieve data from Variant Table
Can anyone help me by telling how to retrieve data from variant table which was created by user. I am able to see data of variant table only thru cu60 transaction but not se11. I s there any function module to do this?
Hello Mohan,
if u already have data and u want to populate it in F4 help then use below code -
u Have to make use of FM - 'F4IF_INT_TABLE_VALUE_REQUEST'
REPORT ZGILL_VALUE_REQUEST .
data: begin of lt_all occurs 0.
include structure DYNPREAD.
data end of lt_all.
data: begin of lt_selected occurs 0.
include structure DDSHRETVAL.
data: end of lt_selected.
DATA: BEGIN OF lt_code OCCURS 0,
code LIKE zgill_main-PERNR,
END OF lt_code.
data no_dyn like sy-dynnr.
Parameters : ECODE like zgill_main-PERNR.
*parameters: pernr like pa0001-pernr .
no_dyn = sy-dynnr. "give the scren no directly or sy-dynnr in case of report.
At selection-screen on value-request for ECODE.
select PERNR into table lt_code from zgill_main.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
retfield = 'ECODE'
dynpprog = sy-repid
dynpnr = no_dyn
dynprofield = 'ECODE'
window_title = 'Employee Details'
value_org = 'S'
DISPLAY = 'F'
TABLES
value_tab = lt_code
RETURN_TAB = lt_selected.
EXCEPTIONS
PARAMETER_ERROR = 1
NO_VALUES_FOUND = 2
OTHERS = 3
*if sy-subrc eq '0' .
write: 'success'.
*endif.
read table lt_selected index sy-tabix.
move lt_selected-fieldval to ECODE. -
How describe model data and get select in DB throw topLink.
Hello,
I have table from code
create table t_tree
id int primary key,
parent_id int,
value varchar2(255)
Alter table t_tree
add constraint constr_id_parent foreign key (parent_id) references t_tree (id)
I must get query
select level as lv,lpad('-@-', (level-1)*2)||value as MMM, t.* from t_tree t
connect by prior id=parent_id
start with T.PARENT_ID is null
How describe model data and get select in DB throw topLink.
Dema.So you'll probably have to write a function which uses dynamic SQL to retrieve the desired message text, like this untested one:
CREATE OR REPLACE FUNCTION get_msg(p_db IN VARCHAR2,
p_id IN NUMBER)
RETURN VARCHAR2
IS
msg_txt VARCHAR2(4000);
BEGIN
-- make sure p_db is a valid database link ...
EXECUTE IMMEDIATE 'SELECT d_msg FROM msg@' || p_db || ' WHERE t_id = :id' INTO msg_txt USING p_id;
RETURN msg_txt;
EXCEPTION
WHEN NO_DATA_FOUND THEN
RETURN NULL;
END get_msg;
/The you can update likeUPDATE mex
SET t_msg = get_msg(db_id, t_id);Hth, Urs -
How to retrieve data from table(BOM_ITEM)
Hi All,
I wrote webservices using axis1.4 to get BOM information from SAP.. funtional module is CAD_DISPLAY_BOM_WITH_SUB_ITEMS
webservices works fine..I'am able to retrieve data from Export Parameter..But not able to retrieve data from table
How to retrieve data from table(BOM_ITEM)..?
Cheers, all help would be greatly appreciated
VijayHi,
1. Create Page Process.
2. Select Data Manipulation
3. In category select "Automated Row Fetch"
4. Specify process name, sequence, select "On Load - Before Header" in point.
5. Specify owner, table, primary key, and the primary key column(Item name contains primary key).
6. Create a process.
7. In each item select "Database Column" in "Source Type".
Regards,
Kartik Patel
http://patelkartik.blogspot.com/
http://apex.oracle.com/pls/apex/f?p=9904351712:1
Maybe you are looking for
-
Hi Experts, In our project we have the requirement that Security Deposit will be posted at contract account level , but payments may come with reference to Contract and even then the payment should clear the SD on priority basis. In standard I have c
-
I have a calibrated monitor. I have set up the proper profile for my epson 1400 printer using only epson ink. I am using PSE 5.0 and am perfectly happy with it.Working on Win Vista Business. I tried "soft proofing" in Quimage and was not happy with i
-
Hi there, does anyone of ou know whether you can call a Web Service that runs inside the WAS via JMS. I do not men MDBs or sth like that. Simply replacing http by jms. I consider this option since the jms connection is not encrypted and I want to pro
-
AVI to MP4 - retaining original quality.
I am converting old (1999/2000) avi files to MP4 output. I'm using CS6. What is the best export setting to do this. The original recordings were onto DV Tape. The AVI files were outputs from Premiere v5 , 5.5 or 6 (years ago) I've noticed that usin
-
PC guy trying to backup all Wife's iPhotos, crashes...pls help.
Hi Everyone, My Wife is camar crazy and shes got almost over 100Gb of photos in iPhoto. I need to back everything up... I've read all the topics on simply moving the iPhoto folder to the external, which works. Only thing is it crashes after about 2/3