30 day money-back guarantee
Read more...
9 EUR lifetime license
15 EUR lifetime license
(nofollow link from sponsors page)
| 23% | | United States | | 15.7% | | India | | 7.3% | | Russian Federation | | 7% | | Colombia | | 6.1% | | Germany | | 5.2% | | United Kingdom | | 4.4% | | Poland | | 3.4% | | Netherlands | | 3% | | France | | 2.8% | | Canada |
| Today: | 730 | | Yesterday: | 1639 | | This Week: | 3955 | | Last Week: | 10059 | | This Month: | 10654 | | Total: | 33968 | |
Users| Most active users today from total of 27: | | matto, rottenberg, dontbugmeplease, Adelavigne, eghtedar, manuelflores, rockiesrider, michmich, infomech, Andii S., jacek2011, Me2, iwm, mirkogeo, sstinfo, texa, stecho, rifki, openaspace, blombo | |
JoomlaWatch is popular joomla visitor tracking and live stats component. It provides several features such as spam blocking,
goals tracking, charts, nightly email reports, latest visit map, interactive HTML5 traffic flow graph and many other useful functionalities,
which will help you to optimize your site.
Freelance
Projects
Forum
Resources
|
Here are some of my notes from HTML, Servlets, JSP Course:
ServletsgetPathInfo() - 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"
pluginsusage: < jsp:plugin > ... < /jsp:plugin >
it inserts Java applet to the page
System environmentsusage:
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");JavaBeansrequirements 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.
usage in a JSP page:
< jsp:useBean id="nameOfBean" scope="session" class="myPackage.Counter" />
< jsp:getProperty name="nameOfBean" property="myCount" />
this is the same as
<%= Counter.myCount %>
with JSTL Expression language:
< c:out value="${Counter.myCount}" >
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
Sending e-mail
package sun.netsmtp.SmtpClient; SmtpClient smtp = new SmtpClient("...IP.."); smtp.from(from); smtp.to(to); PrintStream msg = smtp.startMesage();
msg.println(....);
smtp.closeServer();
- attachments cannot be inserted
JavaMail API- more complex
- XSD is exchange for DTD
|
Add comment
|