Ganesh Chinni

Greenhorn
+ Follow
since Dec 30, 2005
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
(keep public parts private until JForum day)
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt
Moderation Tools

Recent posts by Ganesh Chinni

Just in case if you wanted a sample code to dynamically add rows to table,

DefaultTableModel model;
JTable table;

model = new DefaultTableModel();

model.addColumn("Name");
model.addColumn("Phone");

table=new JTable(model);

for(i=0;i<=5;i++) {
Object[] rowData = {"XYZ","1236"};
model.insertRow(i,rowData);
}


Regards,
Ganesh
SCJP
SCWCD
SCBCD
[ October 24, 2007: Message edited by: Ganesh Chinni ]
10 years ago
When you declare the array int[] a=new int[1]; the element a[0] is initialized to 0.
you are passing the reference of the array to modify method and the modify method changes the value of the reference and hence you can see the changed value of a[0] out side the modify method.

Remember, in Java its always pass by value. When you pass a basic data type then the value of it is sent to the called method and when you pass the objects the value of the objects reference is sent to the called method. In short, for your understanding you can treat this as "for basic data types its pass by value and for objects its pass by reference".

Regards,
Ganesh
SCJP
SCWCD
SCBCD
[ October 12, 2007: Message edited by: Ganesh Chinni ]
Hi,

Any sun certification exam can be taken from a prometric center. Go to any prometric center and tell them when and which exam you would like to take and hand them over DD or cash, rest all will be taken care by the center. All you need to do would be is to go the prometric center and give the exam on the scheduled date.

Fees for SCJP is 7,500rs.

Regards,
Ganesh
SCJP
SCWCD
SCDBC
Post the servlet code that you are using to get the request parameter.
11 years ago
Hi Nilesh Sah,

Did you restart the server after changing the web.xml?
And where is the <session-config> element placed in the web.xml?


Also, are you checking if the session is null before processing the request?

Before processing the request, check if session is null, the session will be null if it has timed out(or invalidated). If session is null then do what you need to do if the session is invalid. I mean process the request only if the session is not NULL.


Regards,
Ganesh
SCJP 1.4
SCWCD 1.4
SCBCD 1.3
11 years ago
change ur web.xml as follows,

<url-pattern>/SERVLET/*</url-pattern>
11 years ago
Hi,

You can include servlet.jar in the classpath while compiling the Servlet classes using javac -classpath option.

For example, if your servlet name is ExampleServlet and if your servlet.jar is present in "/Users/Ganesh/" directory then to compile your servlet you can use the following command.

javac -classpath .:/Users/Ganesh/Servlet.jar ExampleServlet.java


If your servlet.jar is present in the same directory as the ExampleServlet then include ".:" in your classpath.


Regards,
Ganesh
SCJP 1.4
SCWCD 1.4
SCBCD 1.3
11 years ago
HI,

Q19. When you call request.getParameterNames() method, you will get Enumeration as a return value and the Enumeration will store all the parameter names(not the parameter values) that were sent as part of the request.

so after calling request.getParameterNames(),you will iterate through the Enumeration to get all the parameter names one by one and once you get the parameter names then you can call the request.getParameter(String parameterName) method to get the actual value of the parameter.


Q 47. Option D means you can call invalidate() method from a servlet to invalidate the session.
Hi,

You only need to know how to declare them in web.xml for the exam.


Regards,
Ganesh
SCJP 1.4
SCWCD 1.4
SCBCD 1.3
Hi,

If you are displaying values in some input boxes in your current servlet then you can reterive the same in the next servlet using(provided the input boxes are inside the <form> tag),

Request.getParameter(String parameterName) method.

The second case is, if you are displaying it as labels in the current servlet then u can use hidden fileds in your current servlet and populate the hidden fields with the values. Then on Submit of the form you can retrive the same values in your next servlet using the same method mentioned above.


If you are not using the submit button, instead if you are using a hyper link to go to the next servlet then you can append the values at the end of the URL as follows(example),

http://localhost/WebApp/Servlet2?userName=xyz,

then you can retrive the id value in your next servlet as follows,
String name = request.getParameter(userName);


Hope this helps you.

Regards,
Ganesh
SCJB 1.4
SCWCD 1.4
SCBCD 1.3
11 years ago
Hi,

I would suggest you the following books,

1. UML Distilled by Martin Flower
2. Design patterns by Erich Gamma
3. Head First EJB (need not refer if if you are already SCBCD).


Regards,
Ganesh
SCJP 1.4
SCWCD 1.4
SCBCD 1.3
You can use Core servlets and JSP book for learing Servlets and JSP(you can get the free pdf version of this book on the net).

For learing EJB you can use Mastering EJB book. but as suggested by the other people, i will also suggest you not to start EJB untill you learn Servlets and JSP.


But if you are planning for SUN certification then use Head First series.

Regards,
Ganesh
SCJP 1.4
SCWCD 1.4
SCBCD 1.3
11 years ago
To keep these values thread safe, store these values in request attribute or store them as local variables.

Do not store the userlogin value in a class variable.


Regards,
Ganesh
SCJP 1.4
SCWCD 1.4
SCBCD 1.3
11 years ago
Can you explain why do you want to put user name in the headder and send it, when there are other ways to send the parameter.

Putting username in headder is not a good idea.
11 years ago
After the zip file is sent to the client, the browser throws up options to the user and based on the option selected by the user(save,extract, open ..etc), the zip file is handled.

Regards,
Ganesh
11 years ago