GeeCON Prague 2014*
The moose likes Other Open Source Projects and the fly likes capacha Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "capacha" Watch "capacha" New topic
Author

capacha

Suresh Khant
Ranch Hand

Joined: Feb 27, 2010
Posts: 118
Hi All ,
I am trying to implement capatcha in jsp application , using jcapatcha : i have the following

web.xml



index.jsp




CaptchaServiceSingleton.java




ImageCaptchaServlet.java




when calling servlet jcapacha , i am getting null pointer





any suggestion how to implement it .

Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42061
    
  64
So which object is null? And in which line of code does the exception happen?


Ping & DNS - my free Android networking tools app
Suresh Khant
Ranch Hand

Joined: Feb 27, 2010
Posts: 118
Thansk for your reply,


exeception happened in this line :
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42061
    
  64
Ulf Dittmer wrote:So which object is null?

challenge or jpegEncoder? Once you know which one it is, check the javadocs of all methods you're calling to create these objects to learn under which circumstances they might return null.
Shashank Ag
Ranch Hand

Joined: Dec 22, 2009
Posts: 88

I am just gussing but it looks like challenge is null which is returned by the method you created.


SCJP 91%, SCWCD 97%
Suresh Khant
Ranch Hand

Joined: Feb 27, 2010
Posts: 118
Hi Thanks All for the replies

After long search and checking , I have found the exact Problem .

By the way i was using openjdk I was getting the the null pointer exception (jpegEncoder was null) but i have tested the same code using sun jkd and it works fine .

the got the tip from :

OpenJDK does not have a native JPEG encoder, try using Sun's JDK, or using a library (such as JAI

AFAIK, regarding the "pinkish tint", Java saves the JPEG as ARGB (still with transparency information). Most viewers, when opening, assume the four channels must correspond to a CMYK (not ARGB) as thus the red tint.

If you import the image back to Java, the transparency is still there, though.

from the link


my question now is How to implement that using jai so that i could run it using openjdk


Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42061
    
  64
If you're just trying to read or write a JPEG image, use the ImageIO class - it is available on all JDKs. That's much preferable to using JAI. If you're doing something else, tell us in more detail what that is.
Suresh Khant
Ranch Hand

Joined: Feb 27, 2010
Posts: 118
Thanks Ulf Dittmer ,

I am creating image for the capacha purpose , by the way I have already post the related code in my first post.
Suresh Khant
Ranch Hand

Joined: Feb 27, 2010
Posts: 118
Any suggestion
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: capacha