Win a copy of Machine Learning Systems: Designs that scale this week in the Scala forum
or Xamarin in Action: Creating native cross-platform mobile apps in the Android forum!

Sheikkadar Mohamedsahib

Greenhorn
+ Follow
since Nov 24, 2013
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Sheikkadar Mohamedsahib

Thanks Tim. As I have placed my properties file inside war file !
4 years ago
Dear Team,

I am looking forward to code to load the properties file from server/bin directory in servlets. Please let me know how to load that ?.

I dont want to keep that properties inside of my .war file.

Thanks,
Sheik
4 years ago
Thanks Joe !!

We have already been tried to validate the captcha code using session.setAttribute from servlets code. In my jsp we are using session.getAttribute to get that generated captcha code. My problem occurs on everytime if i do reload the page, it is returning old session object value.

In this case, how do i validate that captcha code. I agreed with you that captcha generated code should not be kept in JS.

Please guide us.

Please find the following source code using in our application:

jsp:

<img src="captcha" >
<%= session.getAttribute("captchacode")%>

servlets :

Random rdm = new Random();
int rl = rdm.nextInt();
String hash1 = Integer.toHexString(rl);
capstr = hash1.substring(0, 5);
session.setAttribute("captchacode", capstr);

Thanks,
Sheik
4 years ago
We are using servlets to generate captcha code.
4 years ago
I am building a web application for Online Visa Processing. Before submitting a form, i need to get value from user and validate that captcha code.

Please help us on this requirement.

Please find attached the screenshot for the same.
4 years ago
Thanks william. How to validate that code on button click ?
4 years ago
Iam implementing same logic in servlets.. Here I have a query.

Below is my jsp
--------------------

<img src="captchareload.jsp" id="id_captcha"> <input type="button" name="button2" value="Reload" onClick="doRefreshCaptcha();">
<input type="button" value="Validate Confirm Code" >

Here I have used to ajax in the mehtod doRefreshCaptcha() to my captcha servlets.

Assume that servlets generating captcha code. My Question is how to set that generated captcha code to img attribute ? And also how to validate the captcha code on Validate Confirm button click ?

Please reply...

4 years ago
Dear Team,

I have written below jsp code to generate captcha jpg image to output response in JSP. Here I'm getting the following error message as "java.lang.IllegalStateException: getOutputStream() has already been called for this response".

How to handle this issue ? Iam running out of any idea .

Thanks
Sheik

<%@ page import="java.io.*" %>
<%@ page import="java.awt.*"%>
<%@ page import="java.awt.image.*"%>
<%@ page import="javax.imageio.ImageIO"%>
<%@ page import="java.util.*"%>
<%
int width=75;
int height=35;
Random rdm=new Random();
int rl=rdm.nextInt();

String hash1 = Integer.toHexString(rl);

String capstr=hash1.substring(0,5);

session.setAttribute("captchacode",capstr);

Color background = new Color(204,204,204);

Color fbl = new Color(0,100,0);

Font fnt=new Font("SansSerif",1,17);

BufferedImage cpimg =new BufferedImage(width,height,BufferedImage.TYPE_INT_RGB);

Graphics g = cpimg.createGraphics();

g.setColor(background);

g.fillRect(0,0,width,height);

g.setColor(fbl);

g.setFont(fnt);

g.drawString(capstr,10,25);

g.setColor(background);

//g.drawLine(10,17,80,17);

//g.drawLine(10,22,80,22);

try
{
response.setContentType("image/jpeg");
OutputStream strm = response.getOutputStream();
if(response !=null && strm !=null)
{
ImageIO.write(cpimg,"jpeg",strm);
cpimg.flush();
strm.close();
}
}
catch(Exception e)
{
e.printStackTrace();
System.out.println(e.getMessage());
}
%>
4 years ago
Dear Team,

In my application, From my JSP Iam calling servlets on POST request. In my servlets using JNDI Datasource to create a database connection (SQL) to execute INSERT query. Inside init method, I have created this connection. Problem now is that for every refresh of jsp page, init method is not executing. I knew it will be called only once. How to handle it ?



4 years ago
Need quick response on this issue
4 years ago
Dear Friends,

I Am new to this group. Hope get some response for below issue.

I have created one web applications using struts and hibernate Frameworks which is used to insert datas into the database. Getting following error message on performing some action in my page. Error message as

exception

javax.servlet.ServletException: Filter execution threw an exception

root cause

java.lang.ExceptionInInitializerError
src.contact.util.HibernateUtil.<clinit>(HibernateUtil.java:34)

At the same time, I dont any errors in Glass Fish Server.

Please help me out from this issue.

Thanks & Regards,
Sheikh
4 years ago