Deepak Bobal

Ranch Hand
+ Follow
since Feb 06, 2008
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
3
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 Deepak Bobal


output
File is written
Data is 84
104-- T
105-- h
115-- i
32-- s
105--
115-- i
32-- s
84--
101-- T
120-- e
116-- x
32-- t
102--
105-- f
108-- i
101-- l
-1-- e


read() of FileReader class , returns int value but at line 3 it seems that it returns array of integers as i apply while loop on it.I dont understand output "Data is 84 " from line 2 . how this 84 is coming.

Thank You


Above code complies fine.But is there a way to find which add() is being implemented in class.

and if i change it this way




this also compiles fine without any error.

Is there a way to distinguish the method of class from interface method while using in class
As some other languages supports it like vb.
Thank you Tom.

output of your program is -

First reference to Color is next
this.color = Red
this.color = White
this.color = Blue
this.favorite = true
COLOR.RED is Red

So do i consider that all the constructors of enum are invoked with a single call of an enum.

As at line 17 we call only RED but WHITE is called automatically.


Output-
Color is called RRR
Color is called YYY
Color is called GGG

but i expect that only Green constructor should be invoked and output would be "Color is called GGG"

Moreover if i create an overloaded constructor with two parameters and if only that is invoked ,we get rest of the constructors called too.

Does it happen in case of enum unkile to class contructors?
i noticed 32 as max pool size under configuration of glass fish.
it's surprising

there are 32 active bean instances in pool

but while running 20 times it picks only the same instance
this is stateful bean

package com.example;

import com.sun.xml.internal.ws.message.stream.StreamAttachment;
import javax.ejb.Stateless;


@Stateless
public class SprojBean implements SprojRemote {

String myName;
public boolean chek(String name)
{
if(name.equals("Deepak"))
{
myName=name;
return true;
}
else
return false;
}

Servlet



package foo;

import com.example.SprojRemote;
import java.io.IOException;
import java.io.PrintWriter;
import javax.ejb.EJB;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


public class SprojServlet extends HttpServlet {
@EJB
private SprojRemote sprojBean;


protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter();
try
{
String name=request.getParameter("uname");
boolean b=sprojBean.chek(name);
if(b)
{
out.println(name+" is Authenticated to Proceed");
}
else
{
out.println("Sorry "+name +" you are not Authenticated to Proceed");
}
out.println("<br>");
out.println(sprojBean.returnMYName());

} finally {
out.close();
}
}
}



and the jsp Client

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<form action="serv.do">
<body bgcolor="orange">
<br>
<br>
<br>

<center>
<h2>
Stateless Bean Demo
<br>
<br>
<hr>
<br>
Enter User Name
<input type="text" name="uname">
<br>
<br>
<input type="Submit" value="Submit">
</h2>
</center>


</body>
</form>
</html>


This is working very good .

But to check the statelessness of the bean i added another web module SecondSproj and there a used another servlet "SecondSprojServlet.java" to call the same bean

Second servlet in Another Module (i am considering this as another client (if i am correct))


package Sfoo;

import com.example.SprojRemote;
import java.io.IOException;
import java.io.PrintWriter;
import javax.ejb.EJB;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


public class SecondSProjServlet extends HttpServlet {
@EJB
private SprojRemote sprojBean;


protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter();
try
{
String Sname=sprojBean.returnMYName();
out.println("Calling From Second Servlet "+Sname);
} finally {
out.close();
}
}
}


if i am giving name as Deepak at index.jsp it show at Servlet "SprojServlet.java " that "Deepak is Authenticated to Proceed"

after this if i run second servlet and call returnMyName()

it shows "Deepak"

but if the bean is stateless so it must return null

as it creates only one object for each client.


Please correct me where i am worng.

Thanking You




Hi All

it started working .

there was the problem of IDe.

Earlier i was using NetBeans 6.5 BETA

Now i worked at 6.7.1 and received result.

Thank You
i am also ..

but now i am going to try this on NetBeans 6.7.1.
Mihai

I 1st i made that only.When that didn't work and gave the same problem .

then i made Modules and now it's also showing the same problem .


Mihai

i have just made a servlet by calling it from Netbeans

so there is default generated code ,that NetBeans give

and when i

right clicj there

i get a drop down

i select Call Enterprise bean

then i get above mentioned problem..


This Remote Interface

package com.example;

import javax.ejb.Remote;


@Remote
public interface StatelessSessionRemote
{
String show();

}



This Is Stateless EJB



package com.example;

import javax.ejb.Stateless;


@Stateless
public class StatelessSessionBean implements StatelessSessionRemote {

public String show()
{
return "Stateless EJB is called ";
}



}



Now i am making a web module

and when i call this EJB from servlet

as--

right click>Call Enterprise Bean

and it asks the bean name

when i select the bean

it shows

Enterprise bean does not support references.