Home>Question Details



Leo -- Thanks for the question regarding "htp best practices", version 11gr1

Submitted on 3-Jan-2008 16:55 Central time zone
Last updated 10-Jan-2008 14:38

You Asked

Can one tell me what the best practice is using the htp package?

Use of the primitive 'prn' procedure, allowing to write real xhtml tags, and minimizing subprogramm outlining?

Use of the somehow 'higher level' 'p' or 'print' procedures, also allowing to write real xhtml tags, allowing to format date and number variables, but requiring some overhead?

Use of the 'high level' tag-specific procedures, generating uppercase non- xhtml compatible tags, simplifying the generation programming, but requiring more overhead?

What's the standard inside Oracle for this? (e.g. for Portal and Apex development?

and we said...

The best practice is....

do not use it directly...
use APEX to have it all generated for you...

http://apex.oracle.com/


There is no way I would be writing htp.p calls today in 2007 - every now and then in a snippet of code in APEX maybe - but no, not seriously.

APEX uses the full suite of the API - the use htf.anchor and the like - but they also use htp.prn and htp.p when it makes sense.

It would be your call at that point, htp.anchor is a "convenience" function - it would be ok to use htp.prn to do the same - just "harder" in many cases.
Reviews    
2 stars direct use of htp   January 4, 2008 - 3am Central time zone
Reviewer: Leo Van Nieuwenhuyse from Huizingen VB Belgium
do not use it directly... 
use APEX to have it all generated for you... 

Although I'm an Apex-lover, there are so many cases (eg. pl/sql portlet development in Oracle 
Portal) where you need to use it directly.

I've been using them for more than 10 years, but I've also been discussing this topic with many 
developers for as many years.

Personally I stick to the prn procedure (clarity of code, minimal overhead, ability to generate 
xhtml, and last but not least: I just need to remember 1 and exactly 1 procedure to do the whole 
job). And when you look at the code generated by loadpsp: except for the mime header - which of 
course can't be generated using prn - it's just 1 procedure that is used: prn!.

But to broaden my view, any suggestions and points of view are welcome.



Followup   January 4, 2008 - 11am Central time zone:

but that would be exactly what I said?

...

There is no way I would be writing htp.p calls today in 2007 - every now and then in a snippet of code in APEX maybe - but no, not seriously.
....
5 stars Happy New year   January 4, 2008 - 5am Central time zone
Reviewer: A reader from London
"There is no way I would be writing htp.p calls today in 2007". I think you mean 2008




Followup   January 4, 2008 - 11am Central time zone:

indeed.
5 stars   January 10, 2008 - 8am Central time zone
Reviewer: Alessandro Nazzani from Genoa, Italy
>>> do not use it directly...
>>> use APEX to have it all generated for you...

>> Although I'm an Apex-lover, there are so many cases (eg.
>> pl/sql portlet development in Oracle Portal) where you
>> need to use it directly.

> but that would be exactly what I said?

Mmmh... perhaps my English is not good enough, but to me it doesn't sound like *exactly* the same 
thing...

Unfortunately sometimes (often?) ApEx is NOT an option.

> APEX uses the full suite of the API - the use htf.anchor and the like

Last time I checked, those API were printing all tags in uppercase, which destroys XHTML 
compliance.

> Use of the primitive 'prn' procedure, allowing to write
> real xhtml tags, and minimizing subprogramm outlining?
>
> Use of the somehow 'higher level' 'p' or 'print' procedures,
> also allowing to write real xhtml tags, allowing to format 
> date and number variables, but requiring some overhead?

I think htp.print (same as htp.p) and htp.prn are the same, with the exception that the latter does 
NOT add a \n character. Am I wrong?

Alessandro


Followup   January 10, 2008 - 2pm Central time zone:

what I said was:

.... There is no way I would be writing htp.p calls today in 2007 - every now and then in a snippet of code in APEX maybe ...


that is what you are saying - there are tiny snippets you'll use here and there - but it would be responsible for something like 1% of the HTML on a page.


3 stars p versus print versus print   January 11, 2008 - 5am Central time zone
Reviewer: Leo Van Nieuwenhuyse from Belgium
Allesandro, you're allmost right.

But the main difference between prn and p is not only the newline character but also the level of 
the procedure:

prn itself is called again from p and print, so there's allways a little overhead: 

your_procedure->htp.p->htp.prn
or
your_procedure->htp.print->htp.prn






All information and materials provided here are provided "as-is"; Oracle disclaims all express and implied warranties, including, the implied warranties of merchantability or fitness for a particular use. Oracle shall not be liable for any damages, including, direct, indirect, incidental, special or consequential damages for loss of profits, revenue, data or data use, incurred by you or any third party in connection with the use of this information or these materials.

About Oracle | Legal Notices and Terms of Use | Privacy Statement