Here are some of my notes from HTML, Servlets, JSP Course:
Servlets
getPathInfo() - path in URL
getPathTranslated() - where the filename is located
Setting the header
response.setHeader("Content-type","es");
utility native2ascii - converts native codepage to UTF-8 encoding. Useful for .property files and localization
Global attributes
this.getServletContext().setAttributes("name", value); - attribute that is visible in the whole application.. for more servlets
JSP
<%-- comment <%! - declaration (it stores the code out of the service method) <%@ - directive (affects translation of JSP to Servlet, compilation.. useful for tuning for specific cases like setting the error page, code page imports, etc.)
XML syntax of JSP page: ... - same as <%!
include
<%@ include file='file.jsp" %> includes file to a page (before translation) - don't recognize if the included file has changed - includes all of the parameters or attributes for included page
or
< jsp:include page="file.jsp" > dynamic include (during the processing of main page), more flexible - this way we can include result of server or other JSP page - explicit parameter passing to included page by < jsp: param name="name_of_parameter" value="value_of_parameter"> tag. for included pages, there is a need for inserting pages without HTML < body > types !
The page directive
<%@ page ... % >
useful for setting additional properties for jsp page like isErrorPage="true|false"
plugins
usage: < jsp:plugin > ... < /jsp:plugin >
it inserts Java applet to the page
System environments
usage:
TERM=vt100
java -D user.term=$TERM
then, we can access this environment variable by:
System.getProperties() - it returns instance of class Property. System.getProperties().getProperty("user.term");
System.getProperties().remove("user.term");
JavaBeans
requirements for JavaBeans:
- there have to be set/get methods specified - has to have public default constructor (without parameters) - it should be in a package - serializable - get/set methods has to have the same data type! - bean cannot modify content of a page!
... in general, JavaBean is a standard Class.
It can be used as a simple component in a JSP page.
- get method has to be fast, and it should be plain and simple.
automatically set the bean attributes from from names (!important!): < jsp:setProperty name="pocetMiest" property="*" />
scope can be:
application - the bean is available in all application, when that's in more JSP pages, one of them can create it once and other JSP pages can use it. It's something like a global object for all application. session - stored data, just for this session request - just for request or forward page - smallest scope, just on a page that is called (forwarded or included)
Custom Tags
- reusability - components which you can download and use on your JSP page (3rd party) - Custom tags can also command the pageflow instead of JavaBean, you can for example terminate a page by some custom tag.
eg. mytaglib.tld - containts a descriptor of tags in XML
usage:
< %@ taglib uri="/WEB-INF/jsp/mytaglib.tld" prefix="first" % > some text ....
or
< %@ taglib uri="mytaglib" prefix="first" % > -> mytablib has to be defined in web.xml - advantage: when changing a tag library, it can be changed only in web.xml instead of changing it manually in every file.
< first: something />
some text ....
< first:something name="myAttribute" value="myValue" / > -> has to be defined in mytaglib.tld !
in tld file: - < rtexprvalue >true|false< /rtexprvalue > - says that we can use in params < %= expression % > eg.: < first:something name="myAttribute" value="< %= expression % >" / >
writing Custom tag class:
- imports javax.servlet.jsp.tagext.*; - class has to implement class Tag or has to extend TagSupport class
method doStartTag() - method that is executed when there is a occurency of a start tag.
pageContext.getOut.print("I will print this"); // in try/catch block
method doEndTag() - method is executed when there is a closing tag.
method getParent() - returns a parent of a current tag;
method release() - there we can release some system resources, etc.
when there is a body of a tag, it has to implement BodyTagSupport instead of simple TagSupport it means, that you can nest multiple tags within the tag content.
method doAfterBody() - for handling nested content
BodyContent bc = getBodyContent(); // content of a tag body
String body = bc.getString(); // convertion to a String
JSPWriter out = bc.getEnclosingWriter(); // enclosing writer of the parent tag.. result can will be written there.
possible return values on the end of a tag handling method :
return SKIP_BODY; (ignores the body of a custom tag in JSP) - skip to handling method doEndTag()
return SKIP_PAGE; - skips the entire following content of a page.
return EVAL_BODY_TAG; - evaluates the body of a tag
return EVAL_PAGE; - we can continue in page evaluation
JSTL (Java Standard Tag Libraries)
- useful tags for creating cycles, we can elliminate scriptlets, - formating messages - internalization - database communication - expression language
expression language
- eases the manipulation with JavaBeans: eg. ${beanName.propertyName} - allow you to evaluate given expression: eg. ${3+5} - ${param["foo"]} - HTML parameters from query string - ${cookie["myName"]} - cookie with name myName
JavaServer faces
- UI components for HTML - saving it's state between calls - we can work with beans on a server - component model for HTML - quite new technology - implements MVC(model / view / controller) pattern as known as Model 2
Registration required
I know that people don't like registering on websites, but I had to
do it. From this moment you have to register first, before you
download any file. This is better, because this way I can give you
quick info about new version of downloadable files (eg. MathGuard)
or some necessary security fixes. Thanks for understanding.
(26.08.2007)
Books about investing and finance
I'd like to recommend you to read a book by Robert T. Kiyosaki -
"Rich Dad, Poor Dad". However many people say it's quite a
controversial book, it gave me a good motivation to improve my
financial intelligence. (23.08.2007)
Fighting with the spam
All of the forms were protected with my own PHP antispam class -
MathGuard, including the forms in the joomla modules I use.
(02.05.2007)
Forum
Converted posts from the old punbb forum to the new joomlaboard
(25.02.2007)
Improvement
Fixed some issues with the freelance registration, added a
possibility to add a new programming resource, reorganized the
structure of the programming resources. (24.02.2007)
New content management system
Codegravity.com is now running on joomla cms :) Added features like
comments, forum etc. I hope you'll like it. Today I fixed the
problem with the comment module which was not showing the correct
images. There is also a new URL structure. For the old urls there
is a 301 (Moved permanently) http redirect. (10.02.2007)
Moved to another hosting
Codegravity.com has been moved to another web hosting -
CustomHosting.sk, from the previous pipni.cz, mainly because of the
mod_rewrite problems and slow loading of the website. Sorry for
some problems that lasted for about an hour. (19.01.2007)
Bookmark feed
The new feed from the del.icio.us has been added to the homepage
codegravity.com. You 'll always have the latest information about
the sites I like and you should visit as well! (21.11.2006)
News improved
Today I improved the news feeds. They are sorted into categories
and I also added some other feeds that may be interested for you.
(31.03.2006)
The Antispam verification
My email form was hijacked by the spam bots and I was recieving a
lots of junk into my mailbox everyday. So, I decided to put a
simple verification in the end of the form. You have to answer the
result of addition of two numbers. Thank you for your
understanding. (07.03.2006)
Java SE 6 Beta Mustang is out !
This beta release is a major milestone in the development of
Mustang. It provides a complete stable snapshot of the final
release functionality. http://mustang.dev.java.net
(20.02.2006)
Google analytics, apply online
Apply online to google-analytics.com. They offer the new way of
analysis of your website visitors. It is very promising, and when
you will recieve the invitation code, you can send me one :) Thank
you :) (13.02.2006)
Money Manager 2 - software for mobile
accounting
FaceRSS - simple JavaServer Facer (JSF)
component
I registered my new project - FaceRSS on freshmeat.net, here is the
description: FaceRSS is a simple JavaServer Faces (JSF) component
that allows you to display news from a specified URL source in one
configurable JSP tag. This allows you to place news feeds on a Web
site in a very simple way. It uses rsslib4j and therefore supports
RSS version 0.9x, 1.0, and 2.0 with Dublin Core and Syndication
namespaces. (06.01.2006)
My new blog :)
Check out my new [jroller.com/page/matto3c] blog on jroller.com
website. Here is the RSS feed [http://jroller.com/rss/matto3c] if
you'd like to add it into your news reader. (14.12.2005)
ERM-II and Slovakia
SLOVAKIA, my home country, is now one step closer to adopting the
common European currency - EURO. At midnight between
November 25 and November 26, the country joined the Exchange Rate
Mechanism 2 (ERM-II) (30.11.2005)
www.jground.com
I established a new website - http://www.jground.com, it's all
based on JSF and it should be all about Java and all other related
things. Enjoy! (25.11.2005)
Swing text antialiasing
Java webhosting
I'm trying a new http://www.move.cz java webhosting on www.move.cz,
but it seems they don't respond to my questions about JSF ;(
(16.11.2005)
Migration from Weblogic to JBoss
Currently I am working on a task: Migration of one J2EE application
from Weblogic to JBoss application server. So, if you have any
suggestions or resources, I would be glad if you'll send me some.
Thanks (15.11.2005)
Increased Java performance
Java increased its performance on desktop by 58% :
[http://www.javalobby.org/java/forums/t54006.html] Java
Performance
Improvement (15.11.2005)
Exadel Studio Pro
At this time I'm playing with JSF (Java Server Faces). I want to
recommend you a great IDE - Exadel JSF Studio Pro. It costs about
$99, and there is 15 days trial available. You can also try
MyEclipse which has also like Exadel - WYSIWYG editor for editing
JSP, JSF pages. It can save you a lot of time. For more info, visit
www.exadel.com (27.09.2005)
Programming directory
added a new programming resources directory, where you can submit
your own programming website (14.09.2005)
Programming forum
Now the Programming forum is included in website design. I put
there some topics from previous version of this forum.
(19.08.2005)
Ubytovanie, podnajom Poprad
Ponuka na podnajom, ubytovanie: Zrekonštruované podkrovie
- rodinny dom Poprad-Matejovce - 2 izby + pracovna + kúpelna s
kuchynou, strešné a plastové okná,
samostatné plynové kúrenie, drevené
plávajúce podlahy, garáž, velká
záhrada a samostatný vchod. . . Cena: dohodou
Kontakt: 0949 401 409 (18.02.2008)