Saturday, October 8, 2011

Clojure Presentation

https://dl-web.dropbox.com/get/Public/Going_Functional_with_Clojure_Public.pdf?w=d4b0214a

Tuesday, August 5, 2008

Nasty JVM error

JDWP exit error JVMTI_ERROR_WRONG_PHASE(112): on getting class statusFATAL ERROR in native method: JDWP on getting class status,

http://forums.sun.com/thread.jspa?messageID=10260035

Tuesday, July 29, 2008

JavaScript - The features I never knew

These are videos are by Douglas Crockford who is an authority on Javascript. He is a Javascript architect at Yahoo! and also the creator of JSON.


http://video.yahoo.com/watch/111594

This is part 2 0f 4.

Have to watch others as well

Thursday, July 10, 2008

Spring Configuration Issue - How to specify path to config file

BeanFactory factory =
new XmlBeanFactory(new FileSystemResource(".\\src\\applicationContext.xml"));


where "applicationContext.xml" is the spring configuration file's name.

Note: It is assumed that this file is under folder "src"

Method #2:
Better use ClassPathResource instead. This obviates the need for
using the entire path to the physical file.

It works since src is on the classpath.

Eg:
import org.springframework.core.io.ClassPathResource;
BeanFactory factory =
new XmlBeanFactory(new ClassPathResource("applicationContext.xml"));

Saturday, March 1, 2008

Steps in Making use of a Tag Library Validator

Step 1: To use a tag library validator, we need to have a Tag library descriptor
(TLD) file first


What exactly is a TLD file?
-- TLD file is an xml file which describes what restrictions apply to the JSP page in which it is referred.

Where to place the TLD file?
--Under WEB_INF/lib in a dynamic web project under Eclipse.

What does it have?
-- XML header describing the deployment descriptor DOCTYPE. The deployment descriptor
includes the elements and configuration information of a web application.
             PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.1//EN"
"http://java.sun.com/j2ee/dtds/web-jsptaglib_1_1.dtd">
--Root element is taglib which contains element validator(not the only child ele)

What does a Validator Element look like?
--
validator--root element
validator-class as child
with template text javax.servlet.jsp.jstl.tlv.ScriptFreeTLV

init-param element /s as other children
param-name : allowScriptlets //To disallow scriptlets
param-value: false

The mandatory tag child
name: MyTag
tag-class: tags.MyTagAction //Refer step 2

Step 2: A class that supports the mandatory tag -- The tag handler class (goes
under /webapp/src folder)


import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.*;

public class MyTagAction extends TagSupport //Extends Tag--can also use BodyTagSupport
{
static final long serialVersionUID =1;
public int doStartTag() throws JspException
{
//Other Tag handler Methods are doEndTag,release
return SKIP_BODY; // Can also have EVAL_BODY_TAG or EVAL_BODY_INCLUDE
}
}

Further Info here:
http://jakarta.apache.org/taglibs/tutorial.html#basic_tag_library

Step 3: Modify the web.xml file to help the container identify the taglib

Add this to the web.xml file in the webapp.

--jsp-config element
-- taglib element
--taglib-uri-- http://java.sun.com/sample_uri --/taglib-uri--
--taglib-location-- /WEB-INF/restrict.tld --/taglib-location--
--/taglib--
--/jsp-config--


Q: Why have taglib as jsp-config's child?
Refer:http://www.myeclipseide.com/PNphpBB2-viewtopic-t-5656.html

Step 4: Testing the restrictions in a JSP file

<%@ taglib uri="http://java.sun.com/sample_uri" prefix="test"%>

If we do use a scriptlet/s in this JSP page now, the validation fails and the error message
is:

org.apache.jasper.JasperException:


Validation error messages from TagLibraryValidator for Tag library descriptor in /parser.jsp

null: JSP page contains 2 scriptlets.


That's it for now folks...

--Phani

Thursday, February 28, 2008

Observation: Stupid fact

My post after a long hiatus...

This one is regarding request parameters in HTTP.

Being implemented as a HashMap, while retrieving the request parameters order wasn't guaranteed. Should have been obvious...But stupid me...was atleast able to go to a good discussion on the issue.

Here it is..
http://www.velocityreviews.com/forums/t297612-get-request-parameters-are-not-in-order.html

Transcript:




Go Back Velocity Reviews > Newsgroups > Java
User Name
Password
Register FAQ Members List Calendar Today's Posts

Reply

Java - get request parameters are not in order

Thread Tools Search this Thread
Old 06-07-2006, 12:53 AM #1

Default get request parameters are not in order


Here's the code fragment to enumerate the request parameters list, but
the order
is not the same as in the query string.

http://localhost:9999/projWeb/EStore...=1&b=2&c=3&d=4

==========================
Code
==========================
for (Enumeration e = req.getParameterNames(); e.hasMoreElements()
{ Object obj = e.nextElement();
String key = obj.toString();
String value = req.getParameter(key);
out.println(key + "," + value + "
");
}

==========================
output
===========================
b,2
a,1
sub,Logon
d,4
c,3

any ideas?

please advise. thanks!!
John.



John
Reply With Quote
Old 06-07-2006, 01:28 PM #2
Matt Humphrey

Posts: n/a
Default Re: get request parameters are not in order


"John" <> wrote in message
news: oups.com...
> Here's the code fragment to enumerate the request parameters list, but
> the order
> is not the same as in the query string.
>
> http://localhost:9999/projWeb/EStore...=1&b=2&c=3&d=4
>




The parameters are name-value pairs without any presumption of order. They
are probably stored in a HashMap and the enumeration order depends on the
hashing. I tried your code and the parameters came back in mixed order for
JBoss 4.0.2.

I searched through various javadocs and could not find anything that says
the parameters should be retrievable in their original order. If your
design relies on parameter order, something is going to have to change.
Also, I don't think there's any guarantee that forms or other external
sources will put the parameters in the textual order given, or that URL
transforms (URL rewriting) will preserve the order.

If you can't change the design, you can retrieve the original query string
(getQueryString) and pick off the parameters yourself. There are some
libraries to do this, although I don't know their names. Especially for POST
requests, reading the body as a stream may interfere with the ability to
read the names in order.

Cheers,
Matt Humphrey http://www.iviz.com/


Reply With Quote
Old 06-07-2006, 07:10 PM #3
Andy Flowers

Posts: n/a
Default Re: get request parameters are not in order

John wrote:
> Here's the code fragment to enumerate the request parameters list, but
> the order
> is not the same as in the query string.
>
>
>


>
> any ideas?
>
> please advise. thanks!!
> John.
>


The order is not guaranteed and can be affected by the the sending client and
the receiving server.

Why do you need to read the parameters in a specific order ?

If you need to do that then you will have to do the ordering yourself, possibly
by appending a number to the parameter name to give the order,

i.e.

http://localhost:9999/projWeb/EStore...am3=3&param4=4

and then parsing this using the know prefix 'param'.
Reply With Quote
Old 06-08-2006, 03:34 AM #4
Owen Jacobson

Posts: n/a
Default Re: get request parameters are not in order

On Wed, 07 Jun 2006 18:10:31 +0000, Andy Flowers wrote:

> John wrote:
>> Here's the code fragment to enumerate the request parameters list, but
>> the order
>> is not the same as in the query string.
>>
>>
>>

>
>>
>> any ideas?
>>
>> please advise. thanks!!
>> John.
>>

>
> The order is not guaranteed and can be affected by the the sending client and
> the receiving server.


No, only by the receiving server. According to the HTTP and URL/URI
specifications the URLs

http://www.example.com/someapp/servlet?a=foo&b=bar
and
http://www.example.com/someapp/servlet?b=bar&a=foo

are distinct resources. The Java servlet specification allows the
servlet container to reorder request parameters because in practice those
are more often the same resource with two names than two distinct
resources, and storing the parsed parameters in a hashmap is far faster
than seeking through them in order.

IMO parameters should probably be provided in a LinkedMap or LinkedHashMap
stored in URL order, because there are some useful idioms based on
multiple occurrences of the same parameter, but I haven't written a
servlet container or plugin, so my opinion's worth the electrons to print
it and not a bit more.

Owen
Reply With Quote
Old 06-08-2006, 05:47 PM #5
Henry Townsend

Posts: n/a
Default Re: get request parameters are not in order

Owen Jacobson wrote:
> IMO parameters should probably be provided in a LinkedMap or LinkedHashMap
> stored in URL order, because there are some useful idioms based on
> multiple occurrences of the same parameter, but I haven't written a
> servlet container or plugin, so my opinion's worth the electrons to print
> it and not a bit more.


At least in Tomcat my experience has been that repeated parameters are
always returned in order. I.e. using getParametervalues() with:

http://www.example.com/someapp/servlet?a=X&a=Y&x=Z

returns an array in the "natural" order. I agree this is a useful idiom
and could be a solution for the OP, but I don't see it guaranteed
anywhere in the spec.

HT
Reply With Quote
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump



Saturday, February 16, 2008

Eclipse, Apache Tomcat, Servlets

Found a couple of wonderful tutorials on

a)Configuration of Tomcat for Servlet and JSP Development

Link @ coreservlets.com
http://www.coreservlets.com/Apache-Tomcat-Tutorial/#Java-Home

b)Using Eclipse IDE for developing your first servlet

Link @ java-tips.org
http://www.java-tips.org/java-tutorials/tutorials/introduction-to-java-servlets-with-eclipse.html