Akash Bhatt

Greenhorn
+ Follow
since Jul 26, 2005
Merit badge: grant badges
For More
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 Akash Bhatt

Hi All,

I'm preparing to take SpringSource Certified Professional.

Does anybody know where in India, can I get the required 4 day training ?

Thanks in Advance.
14 years ago
Hi all.. I cleared SCWCD today.. though the scores may not be that good but i m quite satisfied. I would like to thank everyone out here for helping through their queries.. i might not have posted a lot but sure i was here many times browsing through various threads.. I would also thanks Bert,Kathy,Bryan for their wohderful book HFJS .. which was the only book i prepared from..n also to the numerous mocks that i took before appering for the final exam .. Well for those who are in pursuit.. stick to the book and work hard with mocks .. thats it... All the best. .
Time To change Signature ..
17 years ago
I am devloping a Web Application with EJBs on WebSphere. Log4j is being used to log the user actions. I am using NDC to specify the user specific information on the logs generated. The problem is that sometimes NDC works and sometimes it does not. I dont have a clue why it does so. 'NDC.push()' is included in the LoginModule so that we have the thread information containing the user login info. Similary 'NDC.pop()' is used when the user logs out.
A sample of log is included:
Pattern:
[DATE][<used by NDC>]\n[Calling Class][LEVEL]->[Message]\n\n

AS:
[%d{dd/MM/yyyy HH:mm:ss,SSS}][%53.53x]%n[%-15.15c][%-5.5p]->[%m]%n%n
Log:

[21/07/2006 12:28:49,000][ ]
[war.CoisServlet][INFO ]->[Servlet Initializing...!!]

[21/07/2006 12:29:42,172][ Sess from 127.0.0.1 @ 2006-07-21 12:29:42.125]
[war.CoisServlet][INFO ]->[USER logins the app as akash akash]

[21/07/2006 12:29:42,172][ Sess from 127.0.0.1 @ 2006-07-21 12:29:42.125]
[war.CoisServlet][INFO ]->[Going for Login through Servlet]

[21/07/2006 12:29:42,375][ Sess from 127.0.0.1 @ 2006-07-21 12:29:42.125]
[nbean.LoginBean][INFO ]->[IN UserInfo doLogin asAKASHAKASHc6v5fr62fY5sZD5TkWzwbiF]

[21/07/2006 12:29:42,594][ Sess from 127.0.0.1 @ 2006-07-21 12:29:42.125]
[nbean.LoginBean][INFO ]->[checking ip s]

[21/07/2006 12:29:42,938][ Sess from 127.0.0.1 @ 2006-07-21 12:29:42.125]
[nbean.LoginBean][INFO ]->[ui -> O.NDLS@priya.com AKASH DLI NDLS AKASH O NR 1234 CRIS01 1979 true]

[21/07/2006 12:29:43,391][ Sess from 127.0.0.1 @ 2006-07-21 12:29:42.125]
[war.CoisServlet][INFO ]->[Returning form Login Bean]

[21/07/2006 12:30:06,547][ ]
[war.CoisServlet][INFO ]->[USER -> Initiating Yard Stock Entry for Coach]

[21/07/2006 12:30:06,969][ ]
[war.CoisServlet][INFO ]->[System -> Collected data returning to YardStkImp.jsp]

[21/07/2006 12:30:24,031][ ]
[war.CoisServlet][INFO ]->[USER -> Initiating Submission]

[21/07/2006 12:30:24,062][ ]
[war.CoisServlet][INFO ]->[SYSTEM -> Going into Bean with data]

[21/07/2006 12:30:24,172][ ]
[.YardStkImpBean][INFO ]->[SYSTEM -> In Yard Stk Bean]

[21/07/2006 12:30:28,266][ ]
[war.CoisServlet][INFO ]->[SYSTEM -> Bean Op Completed. Going to YardStkImp.jsp]

[21/07/2006 12:30:28,469][ ]
[war.CoisServlet][INFO ]->[SYSTEM -> Operation Done]

[21/07/2006 12:32:43,062][ Sess from 127.0.0.1 @ 2006-07-21 12:29:42.125]
[war.CoisServlet][INFO ]->[.. going for logout...!!]

[21/07/2006 12:32:43,094][ Sess from 127.0.0.1 @ 2006-07-21 12:29:42.125]
[war.CoisServlet][INFO ]->[..SUCCESSFULL LOGOUT...!!.. thruu servlet]
Well i dont know whether u can specify the size or not using DailyRolloingFileAppender. But if u want to limit the size u may limit the time. The size will automatically reduce as files would be split. Also DailyRollingFileAppender lets u take up the name u want. It only adds up the time info after the name. I hope that is relevent to you...!!
HI dear the certificate shd have been posted at the address which gave to prometric test centre. U can take information from the site.. https://i7lp.integral7.com/durango/do/login?ownername=sun&channel=sun&basechannel=prometric

u need to have ur prometric id
public class XYZ{
ABC obj=new ABC();
mth1{
System.out.println(obj);
}

}
public class C{
public static void main{
XYZ obj1= new XYZ();
obj1.mth1();
}
}

in Class C when main method ends the object for XYZ is eligible for collection by the GC. But happens to the reference 'obj' created in XYZ..??? Is IT too eligible for collection..??
Ya... how cud i b so so carelsss to overlook it .. thanks u both...
My servlet is not able to receive a post request from a jsp. This servlet is a load on start servlet. What could be the reason?
Code of JSP:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD>
<%@ page
language="java"
contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"
%>
<META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<META name="GENERATOR" content="IBM WebSphere Studio">
<META http-equiv="Content-Style-Type" content="text/css">
<LINK href="theme/Master.css" rel="stylesheet" type="text/css">
<TITLE>index.jsp</TITLE>
</HEAD>
<BODY>
<form action="/prologWAR/ProLogServlet" method="post">

<Table>
<TR>
<TD>Enter ID</TD>
<TD><INPUT type="text" name="id" size="20"></TD>
</TR>
<TR>
<TD>Enter Password</TD>
<TD><INPUT type="password" name="passwd" size="20"></TD>
</TR>
<TR>
<TD colspan="2">
<INPUT type="submit" name="sbmt" value="Submit">
</TD>
</TR>
</TABLE>

</form>

</BODY>
</HTML>


Code Of Servlet:


package prolog.servlets;

import java.io.File;
import java.io.IOException;
import java.sql.SQLException;

import javax.naming.NamingException;
import javax.servlet.Servlet;
import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import prolog.DAO.LoginInfoDAO;

/**
* @version 1.0
* @author
*/
public class ProLogServlet extends HttpServlet implements Servlet {

/**
* @see javax.servlet.GenericServlet#void ()
*/
public void destroy() {

super.destroy();

}


private void requestDispatch(
ServletContext ctx,
HttpServletRequest req,
HttpServletResponse resp,
String page)throws ServletException, IOException {
ctx.getRequestDispatcher(page).forward(req, resp);

}

public void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
System.out.println("In doget");

}

/**
* @see javax.servlet.http.HttpServlet#void (javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
*/
public void doPost(HttpServletRequest req, HttpServletResponse resp,HttpSession session)
throws ServletException, IOException {
System.out.println("In doPost");
try{

String Id = req.getParameter("id");
String Passwd = req.getParameter("passwd");
String DBPasswd = LoginInfoDAO.getPass(Id);
if(Passwd.equals(DBPasswd)){
session.setAttribute("res","Login Succeds");
}else{
session.setAttribute("res","Login Fails");
}
requestDispatch(getServletConfig().getServletContext(),req,resp,"index.jsp");
}catch(NamingException ne){
System.out.println(ne.getExplanation());
session.setAttribute("errorflag",ne.getExplanation());
}catch(SQLException sq){
System.out.println(sq.getErrorCode()+" "+sq.getSQLState()+" "+sq.getLocalizedMessage());
session.setAttribute("errorflag",sq.getErrorCode()+" "+sq.getSQLState()+" "+sq.getLocalizedMessage());
}catch(Exception e){
System.out.println(e.getMessage());
session.setAttribute("errorflag",e.getMessage());
}
}



}
package prolog.servlets;

import java.io.File;
import java.io.IOException;
import java.sql.SQLException;

import javax.naming.NamingException;
import javax.servlet.Servlet;
import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import prolog.DAO.LoginInfoDAO;

/**
* @version 1.0
* @author
*/
public class ProLogServlet extends HttpServlet implements Servlet {

/**
* @see javax.servlet.GenericServlet#void ()
*/
public void destroy() {

super.destroy();

}


private void requestDispatch(
ServletContext ctx,
HttpServletRequest req,
HttpServletResponse resp,
String page)throws ServletException, IOException {
ctx.getRequestDispatcher(page).forward(req, resp);

}

public void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
System.out.println("In doget");

}

/**
* @see javax.servlet.http.HttpServlet#void (javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
*/
public void doPost(HttpServletRequest req, HttpServletResponse resp,HttpSession session)
throws ServletException, IOException {
System.out.println("In doPost");
try{

String Id = req.getParameter("id");
String Passwd = req.getParameter("passwd");
String DBPasswd = "xyz";
if(Passwd.equals(DBPasswd)){
session.setAttribute("res","Login Succeds");
}else{
session.setAttribute("res","Login Fails");
}
requestDispatch(getServletConfig().getServletContext(),req,resp,"index.jsp");
}catch(NamingException ne){
System.out.println(ne.getExplanation());
session.setAttribute("errorflag",ne.getExplanation());
}catch(SQLException sq){
System.out.println(sq.getErrorCode()+" "+sq.getSQLState()+" "+sq.getLocalizedMessage());
session.setAttribute("errorflag",sq.getErrorCode()+" "+sq.getSQLState()+" "+sq.getLocalizedMessage());
}catch(Exception e){
System.out.println(e.getMessage());
session.setAttribute("errorflag",e.getMessage());
}
}



}


Code only checks for the password.
Congrates n thanks for those tips....
Hi there .. according to the offical java contract whenever u override equals u need to override hashcode as well. But in case u dont do it, the hashtable of the Object class .. the granddaddy of all the classes..would be inherited.. n it would be used..

the problem with ur code are as follows:
1. ur not using "tbl.put(new Equals(1),"1");" properly ur using a new object of Equlas as a key ....which needs hashcode (n u dont have it.. rt?)

2 "tbl.get(eq1).toString());" here ur trying to get the stored value using the older object created in "Equals eq1=new Equals(1);"..


So since both are different objects (though equal. but without hashcode).. u wont get ur stored value in the used HashTable.

Try this may be u get somthin here string is used as a key which has hashcode overiden

import java.util.Hashtable;

public class Equals {

private int id;

Equals(int id){
this.id=id;
}

public boolean equals(Object obj){
if((obj instanceof Equals)&&(this.id==((Equals)obj).id))return true;
else return false;
}

public static void main(String[] args) {
Hashtable tbl=new Hashtable();
Equals eq1=new Equals(1);
tbl.put("1",eq1);
System.out.println(tbl.get("1").toString());
}


}
there would be one more option in the exam ... depends on the VM
Thanks Sharn that clears all my doubts.. nyways could you please provide the link to those good sun java docs ... ...

Thanks in Advance
no its sure that the there no other refrences in the code then??
public class GBC{

public static void gbtest(){
Vector newvec=new Vector();
///code that uses newvec
// use of newvec over
}
}


Now do we need to set newvec=null explicitly in the method gbtest or since its a local variable it would be destroyed(as it lives on stack) and object refrenced by it would be automatically collected from the heap by gc?

Thanks in Advance
AKASH