• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Hints for SCWCD

 
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ranchers,

I wanted to start a thread for posting some things related to SCWCD...something like points to remember...If anyone has similiar ideas, you can post them here. So to start off,

A jsp:forward effectively terminates the current page. Nothing before the jsp:forward or after the jsp:forward is written to the response! It is not the samw when using a requestDispatcher.forward()
 
Joe San
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here is the second one,

A pageContext implicit object knows about all other jsp implicit objects and it has methods to get hold of them.
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
http://java.boot.by/wcd-guide/
 
Joe San
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Satou,

I'm just putting things here as and when I come across studying them.

So here comes the third one.

Of the big 7 HTTP methods,

SAFE >> GET, HEAD, TRACE, OPTIONS
IDEMPOTENT >> GET, HEAD, TRACE, OPTIONS, PUT, DELETE
NON-IDEMPOTENT >> POST
 
Ranch Hand
Posts: 378
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
had you sit for the test yet?
----
 
Joe San
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No. I'm planning for it sometime in june this year!
 
Joe San
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here comes the next one, perhaps a basic thing

A value of 0 or a negative value in the session-config in the web.xml file (which is expressed in minutes) indicates that the session never expires. However, this can be overridden using the setMaxInactiveInterval() in the code where the time is in seconds.
[ April 25, 2007: Message edited by: Jothi Shankar Kumar Sankararaj ]
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

A value of 0 or a negative value in the session-config


You mean in the session-timeout of the session-config ?
 
Joe San
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes Satou. By the way one more doubt I have is that, when we call invalidate() on the session and then we try to access any methods of the HttpSesion interface, we get an IllegalStateException but we don't get this exception for the get and setMaxInactiveInterval(), and getServletContext() methods?? WHY??
 
Joe San
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The next one,

Beware of the deprecated encodeUrl and encodeRedirectUrl methods. They have mixed casing for the Url.
 
Ranch Hand
Posts: 304
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Jothi,

Could you please let me know what do you meant by saying "mixed casing"?
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Could you please let me know what do you meant by saying "mixed casing"?


In HttpServletResponse, there are both encodeUrl and encodeURL. The former is deprecated. Same for encodeRedirectUrl.
 
Joe San
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here comes the next one,

The servlets created from the JSP page have to obey some special rules, a vendor will typically have a specialized jsp base servlet-perhaps extending HttpServlet or GenericServlet. In Tomcat, this is called org.apache.jasper.runtime.HttpJspBase.
 
Joe San
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The next one,

If a jsp page fails to translate, then any request to that page should return a 500(server error) communicated back in the HTTP response.
 
Joe San
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The next one,

Don�t be thrown by weird but legal variants for directive syntax. You don�t need white space after the opening marker or before the closing marker:
<%@page import="java.util.*"%> You can also put extra white space before
or after the equal sign for the attribute: <%@ page import = "java.util.*"%>
Single quotes are as acceptable as double quotes for attribute values:
<%@ page import=ʼjava.util.*ʼ %>
 
Joe San
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The next one,

There are 4 page directives required to be known for the exam. They are,

<%@ Page import...%> -- Can appear any number of times and anywhere in the jsp
<%@ Page session...%>-- Can appear only one time at the top of the page, if left, default is true or in other words the session object is available to the jsp page
<%@ Page contentType...%> -- Can appear only one time at the top of the page
<%@ Page isELIgnored...%> -- Can appear only one time and at the top of the page, by default it is false
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

can appear only one time


Actually, you are allowed to have it multiple times, as long as the value is the same.

There shall be only one occurrence of any attribute/value pair defined by this directive in a given translation unit, unless the values for the duplicate attributes are identical for all occurrences.
 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Let's assume you have a customerBean which has an address property object. This address object has a city property.

so to set the city property of the customerBean.address object using the appropriate JSTL tags?
<c:set target="${customerBean.address}" property="city" value= "${city}" />
 
Yasser Almohammad
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Consider the following code:
public class MyHttpSessionListener implements HttpSessionListener
{
public void sessionCreated (HttpSessionEvent e)
{
System.out.log ("Session Created");
}

public void sessionDestroyed (HttpSessionEvent e)
{
HttpSession session = e.getSession ();
String name = (String) session.getAttribute ("username");
}
}


at code execution, an IllegalStateException will be thrown when the session.getAttribute ("name") is called.
By the time the servlet container calls the sessionDestroyed () method, the session has already been invalidated. Therefore a call to getAttribute () will throw an IllegalStateException.
 
Joe San
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The next one,

Expression Language can be enabled or disabled in three different ways. We
encountered one of these ways in Chapter 6, when we looked at the page
directive settings. The page directive attribute isELEnabled can turn on EL
for a single page�or not.
There are a couple of alternative ways of controlling EL enablement
that aren�t explicit exam objectives. One is with the <jsp-propertygroup>
element, which has a subelement <el-enabled>. We met <jspproperty-
group> in the context of identifying JSP documents (subelement
of <jsp-config> .
Finally, EL is enabled at an application level by having a deployment
descriptor at servlet level 2.4. A previous deployment descriptor level indicates that EL should be switched off.
 
Joe San
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The next one,

You have to keep java code (like scriptlets, expressions) free of EL
 
Joe San
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The next one,

${"Not a Number"+ 3.0}. You will get a javax.servlet.jsp.el.ELException, complaining that �Not a Number� cannot be converted to a java.lang.Double value. This example also goes to show that the addition operator in EL�unlike Java�is not overloaded to handle string concatenation. There�s no operator overloading or string concatenation in EL.
 
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1. It is not correct to assume that everybody is reading David Bridgewater's book .
2. Chapter 6 in HFSJ is on Session Management.
3. There is no isELEnabled attribute for page directive.
4. It is isELIgnored.
5. Instead of just doing cut and paste, it would be better if it is written in one's own words, covering the particular topic in its entirety.
6. jsp-property-group has subelement el-ignored and NOT el-enabled.[ April 26, 2007: Message edited by: Sunder Ganapathy ]
[ April 26, 2007: Message edited by: Sunder Ganapathy ]
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Jothi,
maybe it would be better to collect your hints in one file and put it somewhere where we can access it. Hints without categories may not be very useful for other ranchers.
 
Joe San
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Satou,

It's a good idea what you suggested is to put all the hints in one file arranged topic wise and maybe put it somewhere in the server so that everyone can access it. I'll start working on it right away.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

It's a good idea what you suggested is to put all the hints in one file arranged topic wise and maybe put it somewhere in the server so that everyone can access it.



How about a wiki page right here on JavaRanch? We'd be glad to host it. I've started one here. If you're not strong with wikis, don't worry, someone will clean up the formatting (if necessary). Or you could send the material to one of the moderators (e.g., me) who would put it up for you.
 
Joe San
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Good suggestion Ulf! So how should I go about posting the hints there?? I'm able to see the link that says Scwcd links...I just click the edit button and start typing??

Also you were mentioning some Wiki....are you talking something like a wikipedia kind of in javaranch?? That would also be an interesting thing to do here at the ranch.
 
Joe San
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ulf,

We can try to organize it topic wise. I visited the page and I want to have something like this...Topics in the form of hyperlinks and once you click them it expands with something kind of points to remember like 1,2,3 with examples if necessary...Does this sounds good??
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Information about page formatting of the wikis are here :
http://faq.javaranch.com/view?PageFormatting

The SCWCD FAQ is also made this way. You can try to see how it is built be pressing the "edit this page" button :
http://faq.javaranch.com/view?ScwcdFaq
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm not a big fan of those tables in the SCWCD page (I think they distract from the content), but otherwise the format is nice. It may make less sense if the individual hints do not really have a question or a title to go with them. But there are no absolute rules, and we have pages with many different styles, so I wouldn't worry too much about the layout. Wikis are always evolving, anyway.
 
Joe San
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Alright Ulf, I'll start adding the contents there and may be if you find my language awkward please go ahead and edit them.
 
Joe San
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ulf,

I started adding the contsnts to the page. Maybe you can check at it and let me know if they look okay.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And don't forget to correct the part about "can appear only one time"
 
Joe San
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Satou,

Can the other ones (other than page import) appear anywhere in the jsp page? I'll add this as well in the Scwcd hints...
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Only pageEncoding and contentType should appear at the beginning of the page.
 
Joe San
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Satou!
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That looks good, Jothi. Nice work.
 
Joe San
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ulf,

First of all I should thank you for creating such a space "Scwcd Hints" here at javaranch.

I would be even happy, if I'm able to format the contents better. Like for point number 11 which talks about the difference between <%@ page...> directive and <@ include...> I wanted to have a table and I tried but failed in doing so.
 
Joe San
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It would also be good if fellow ranchers can as well post their hints...well what do you guys say??
 
Joe San
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ulf,

When the Scwcd Hints gets hot, may be we can add a link in the top of the forum. What do you suggest??
 
If a regular clown is funny, then a larger clown would be funnier. Math. Verified by this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic