javascript:void(alert(encodeURIComponent('a+b'))); |
http://cass-hacks.com/articles/discussion/js_url_encode_decode/
http://www.w3schools.com/tags/ref_urlencode.asp
URLs can only be sent over the Internet using the ASCII character-set.
Since URLs often contains characters outside the ASCII set, the URL has to be converted. URL encoding converts the URL into a valid ASCII format.
URL encoding replaces unsafe ASCII characters with "%" followed by two hexadecimal digits corresponding to the character values in the ISO-8859-1 character-set.
URLs cannot contain spaces. URL encoding normally replaces a space with a + sign.
URL Encoding Reference
ASCII Character | URL-encoding |
---|---|
space | %20 |
! | %21 |
" | %22 |
# | %23 |
$ | %24 |
% | %25 |
& | %26 |
' | %27 |
( | %28 |
) | %29 |
* | %2A |
+ | %2B |
, | %2C |
- | %2D |
. | %2E |
/ | %2F |
0 | %30 |
1 | %31 |
2 | %32 |
3 | %33 |
4 | %34 |
5 | %35 |
6 | %36 |
7 | %37 |
8 | %38 |
9 | %39 |
: | %3A |
; | %3B |
< | %3C |
= | %3D |
> | %3E |
? | %3F |
@ | %40 |
A | %41 |
B | %42 |
C | %43 |
D | %44 |
E | %45 |
F | %46 |
G | %47 |
H | %48 |
I | %49 |
J | %4A |
K | %4B |
L | %4C |
M | %4D |
N | %4E |
O | %4F |
P | %50 |
Q | %51 |
R | %52 |
S | %53 |
T | %54 |
U | %55 |
V | %56 |
W | %57 |
X | %58 |
Y | %59 |
Z | %5A |
[ | %5B |
\ | %5C |
] | %5D |
^ | %5E |
_ | %5F |
` | %60 |
a | %61 |
b | %62 |
c | %63 |
d | %64 |
e | %65 |
f | %66 |
g | %67 |
h | %68 |
i | %69 |
j | %6A |
k | %6B |
l | %6C |
m | %6D |
n | %6E |
o | %6F |
p | %70 |
q | %71 |
r | %72 |
s | %73 |
t | %74 |
u | %75 |
v | %76 |
w | %77 |
x | %78 |
y | %79 |
z | %7A |
{ | %7B |
| | %7C |
} | %7D |
~ | %7E |
%7F | |
€ | %80 |
%81 | |
‚ | %82 |
ƒ | %83 |
„ | %84 |
… | %85 |
† | %86 |
‡ | %87 |
ˆ | %88 |
‰ | %89 |
Š | %8A |
‹ | %8B |
Œ | %8C |
%8D | |
Ž | %8E |
%8F | |
%90 | |
‘ | %91 |
’ | %92 |
“ | %93 |
” | %94 |
• | %95 |
– | %96 |
— | %97 |
˜ | %98 |
™ | %99 |
š | %9A |
› | %9B |
œ | %9C |
%9D | |
ž | %9E |
Ÿ | %9F |
%A0 | |
¡ | %A1 |
¢ | %A2 |
£ | %A3 |
%A4 | |
¥ | %A5 |
| | %A6 |
§ | %A7 |
¨ | %A8 |
© | %A9 |
ª | %AA |
« | %AB |
¬ | %AC |
¯ | %AD |
® | %AE |
¯ | %AF |
° | %B0 |
± | %B1 |
² | %B2 |
³ | %B3 |
´ | %B4 |
µ | %B5 |
¶ | %B6 |
· | %B7 |
¸ | %B8 |
¹ | %B9 |
º | %BA |
» | %BB |
¼ | %BC |
½ | %BD |
¾ | %BE |
¿ | %BF |
À | %C0 |
Á | %C1 |
 | %C2 |
à | %C3 |
Ä | %C4 |
Å | %C5 |
Æ | %C6 |
Ç | %C7 |
È | %C8 |
É | %C9 |
Ê | %CA |
Ë | %CB |
Ì | %CC |
Í | %CD |
Î | %CE |
Ï | %CF |
Ð | %D0 |
Ñ | %D1 |
Ò | %D2 |
Ó | %D3 |
Ô | %D4 |
Õ | %D5 |
Ö | %D6 |
%D7 | |
Ø | %D8 |
Ù | %D9 |
Ú | %DA |
Û | %DB |
Ü | %DC |
Ý | %DD |
Þ | %DE |
ß | %DF |
à | %E0 |
á | %E1 |
â | %E2 |
ã | %E3 |
ä | %E4 |
å | %E5 |
æ | %E6 |
ç | %E7 |
è | %E8 |
é | %E9 |
ê | %EA |
ë | %EB |
ì | %EC |
í | %ED |
î | %EE |
ï | %EF |
ð | %F0 |
ñ | %F1 |
ò | %F2 |
ó | %F3 |
ô | %F4 |
õ | %F5 |
ö | %F6 |
÷ | %F7 |
ø | %F8 |
ù | %F9 |
ú | %FA |
û | %FB |
ü | %FC |
ý | %FD |
þ | %FE |
ÿ | %FF |
URL Encoding Reference
The ASCII device control characters %00-%1f were originally designed to control hardware devices. Control characters have nothing to do inside a URL.
ASCII Character | Description | URL-encoding |
---|---|---|
NUL | null character | %00 |
SOH | start of header | %01 |
STX | start of text | %02 |
ETX | end of text | %03 |
EOT | end of transmission | %04 |
ENQ | enquiry | %05 |
ACK | acknowledge | %06 |
BEL | bell (ring) | %07 |
BS | backspace | %08 |
HT | horizontal tab | %09 |
LF | line feed | %0A |
VT | vertical tab | %0B |
FF | form feed | %0C |
CR | carriage return | %0D |
SO | shift out | %0E |
SI | shift in | %0F |
DLE | data link escape | %10 |
DC1 | device control 1 | %11 |
DC2 | device control 2 | %12 |
DC3 | device control 3 | %13 |
DC4 | device control 4 | %14 |
NAK | negative acknowledge | %15 |
SYN | synchronize | %16 |
ETB | end transmission block | %17 |
CAN | cancel | %18 |
EM | end of medium | %19 |
SUB | substitute | %1A |
ESC | escape | %1B |
FS | file separator | %1C |
GS | group separator | %1D |
RS | record separator | %1E |
US | unit separator | %1F |
8 comments:
Hi Jason!
I have to implement connection pooling for a rerport similar to following http://wiki.eclipse.org/Java_-_Execute_Modified_Report_%28BIRT%29
I used your code segment in my ReportRunner class as follows,
...............................
DealerLevelDetails.setupDataSourceAndConnection();
ServletContext sc = req.getSession().getServletContext();
this.birtReportEngine = BirtEngine.getBirtEngine(sc);
//setup image directory
HTMLRenderContext renderContext = new HTMLRenderContext();
renderContext.setBaseImageURL(req.getContextPath() + "/images");
renderContext.setImageDirectory(sc.getRealPath("/images"));
// create ReportDesignHandle object and render the report using IRunAndRenderTask task
String path = sc.getRealPath("/");
BuildDynamicReport buildDynamicReport = new BuildDynamicReport(distributor, transActionType, region, fromDate, toDate, path, locale);
ReportDesignHandle designHandle = buildDynamicReport.createDynamicTable();
IReportRunnable design = birtReportEngine.openReportDesign(designHandle);
IRunAndRenderTask task = birtReportEngine.createRunAndRenderTask(design);
HashMap contextMap = new HashMap();
contextMap.put(EngineConstants.APPCONTEXT_HTML_RENDER_CONTEXT, renderContext);
// using a exiting connection used to create temporary cache tables.
HTMLRenderOption options = new HTMLRenderOption();
// Set the output to servlet output stream
options.setOutputStream(resp.getOutputStream());
options.setOutputFormat("html");
task.setAppContext(contextMap);
task.setRenderOption(options);
// DealerLevelDetails.getConnection() returns an existing connection task.getAppContext().put("OdaJDBCDriverPassInConnection",DealerLevelDetails.getConnection());
task.run();
task.close();
...................
Now report is not running and It gives error messgages like ... DataSource for ds is null . My ReportRunner class still using a buildDataSource() method as follows.
public void buildDataSource( ElementFactory designFactory, ReportDesignHandle designHandle ) throws SemanticException
{
OdaDataSourceHandle dsHandle = designFactory.newOdaDataSource(
"Data Source", "org.eclipse.birt.report.data.oda.jdbc" );
dsHandle.setProperty( "odaDriverClass",
"org.eclipse.birt.report.data.oda.sampledb.Driver" );
dsHandle.setProperty( "odaURL", "jdbc:classicmodels:sampledb" );
dsHandle.setProperty( "odaUser", "ClassicModels" );
dsHandle.setProperty( "odaPassword", "" );
designHandle.getDataSources( ).add( dsHandle );
}
...................
What I want to know is , Is it possible to reusue Connection object in a Report similar to
http://wiki.eclipse.org/Java_-_Execute_Modified_Report_%28BIRT%29
Thanks
-Jestan
Jestan,
The error you are stating sounds like you are not setting the datasource propery of the data set that you have dynamically added. BTW that is really not connection pooling as you are adding a datasource to the report definition, which will get opened when the report is executed.
Jason
Hi Jason !
thanks for your reply. Actually my problem is , I am having a ReportRunner class like http://wiki.eclipse.org/Java_-_Execute_Modified_Report_%28B
and I have to modify the it to enable connection pooling, and I have done some changes in
task.getAppContext().put("OdaJDBCDriverPassInConnection",connection) ; But now I am having some problem in following code.
is there a way to modify following code to enable connection pooling..
........................................
void buildDataSource() throws Exception {
OdaDataSourceHandle dsHandle = designFactory.newOdaDataSource("Data Source", "org.eclipse.birt.report.data.oda.jdbc");
if(BirtPorpertyLoader.topTransferReportDS.equals("dataguard")){
dsHandle.setProperty("odaDriverClass", BirtPorpertyLoader.dataguardDriverClass);
dsHandle.setProperty("odaURL", BirtPorpertyLoader.dataguardConnectionUrl);
dsHandle.setProperty("odaUser", BirtPorpertyLoader.dataguardConnUsername);
dsHandle.setProperty("odaPassword", BirtPorpertyLoader.dataguardConnPassword);
}
else if(BirtPorpertyLoader.topTransferReportDS.equals("live")){
dsHandle.setProperty("odaDriverClass", BirtPorpertyLoader.liveDriverClass);
dsHandle.setProperty("odaURL", BirtPorpertyLoader.liveConnectionUrl);
dsHandle.setProperty("odaUser", BirtPorpertyLoader.liveConnUsername);
dsHandle.setProperty("odaPassword", BirtPorpertyLoader.liveConnPassword);
}
else {
throw new Exception("TopupTransfer report's respective datasource configuration is wrong. 'live' and 'dataguard' are the possible values.");
}
designHandle.getDataSources().add(dsHandle);
}
...............................
...............................
private void buildFooterDataSet(String dataSetName, String transType) throws SemanticException {
OdaDataSetHandle dsHandle = designFactory.newOdaDataSet(dataSetName,
"org.eclipse.birt.report.data.oda.jdbc.JdbcSelectDataSet");
dsHandle.setDataSource("Data Source");
String tableName = "";
if (transType.equals(BuildDynamicReport.RECHARGE_KEY)) {
tableName = this.rechargeDealerLevelDetails.cacheTableName;
}
else if (transType.equals(BuildDynamicReport.TRANSFER_KEY)) {
tableName = this.transferDealerLevelDetails.cacheTableName;
}
StringBuffer buf = new StringBuffer();
buf.append(" SELECT CREDIT_AMOUNT AS DENOM , COUNT(CREDIT_AMOUNT) AS DENOM_COUNT , (CREDIT_AMOUNT * COUNT(CREDIT_AMOUNT)) AS TOTAL_AMOUNT");
buf.append(" FROM "+tableName +" CONNECT BY PRIOR MSISDN = PARENT_MSISDN START WITH MSISDN = '"+this.distributor+"' GROUP BY CREDIT_AMOUNT ORDER BY CREDIT_AMOUNT ");
dsHandle.setQueryText(buf.toString());
designHandle.getDataSets().add(dsHandle);
}
..................................
I have to run the above query using an existing connection object. To do that how i can modify above two methods. Can you give some hints !
Thank you.
-Jestan
What error are you getting?
Are you sure this
task.getAppContext().put("OdaJDBCDriverPassInConnection",connection) ;
connection object is valid?
Hi Jason!
The connection object is valid. BWT can you tell me , how I can modify following lines to use existing connection object to build the DataSet to run the query...
OdaDataSetHandle dsHandle = designFactory.newOdaDataSet(dataSetName,
"org.eclipse.birt.report.data.oda.jdbc.JdbcSelectDataSet");
dsHandle.setDataSource("Data Source");
Thank you.
-Jestan
Jestan,
If you modify the report using the DE API and then run the report with the task.getAppContext().put("OdaJDBCDriverPassInConnection",connection); This should use the connection you supply. This will be the case as long as you add a JDBC connection.
Jason
Hi Jason!
I have solved the "Data source null" problem by using one of your earlier blog.
http://birtworld.blogspot.com/2005/12/using-supplied-connection-with-birt.html
It works perfectly and was a real lifesaver for me. Thanks a lot.
Jestan
Great tutorial! Very informative in how well worded and descriptive you were! You know they say that if one knows how to describe what they want really well, then life is just as good as how you describe it :)
Its great for people who feel like time is running against them and then land on your blog and feel like a whole burden was just lifted off of their shoulder.. I admire and respect people who take
time to make it easier for others.. Thanks a bunch! :)