EJB / EE :: How To Obtain 2 Different SLSB By Two Successive Calls

Oct 4, 2014

I use jboss eap 6.2 under eclipse.I perform a tutorial on EJB and I want to show the difference between a stateless session bean and a statefull session bean. I want demonstrate that the first one keep its state (if it has one) but that 2 successive don't send back necessarily the same SLSB : it send back the SLSB that is ready in the pool. But I don't suceed in obtaining 2 different SLSB by 2 successive call. The system always send me back the same SLSB.

View Replies


ADVERTISEMENT

Servlets :: How To Obtain Contents Of Td

Mar 19, 2014

i have created a table in jsp, i want to obtain the contents of a td at the servlet.For example, here's one td of table:

<td align="center" title="tdun" id="cat"> <%= categoryname %> </td>

I want to get this value in my servlet .

View Replies View Related

Obtain Color From Borders

Oct 10, 2014

I'm doing this project where I need to make a persian carpet using recursive methods. I already have my recursive what I'm trying to implement is the use of color. My method BorderColor draws a square using a random color choose from an array.

public void Cuadrado(Graphics g){
Random color = new Random();
g.setColor(colors[color.nextInt(colors.length)]);
g.drawLine(left, top, right, top);
g.drawLine(left, top, left, bottom);

[Code] ....

What I'm trying to do is getting the color from 4 different corners in order to create a new one and make a recursive call. I already tried using the method getPixelColor from the Robot() object but I quit it because is a recursive method and it may cause trouble with the recursive stack. I created this method to create the new color and then call it in the PersianRug method, but I dont have a clue on how to obtain and implement the new colors.

public int newColor(int c,int c1,int c2,int c3, int a){
int c4=((c+c1+c2+c3)%13)*a;
return c4;
}

View Replies View Related

To Obtain Explanation On Singleton Implementation

Jan 11, 2014

I've found following code for Singleton Implementation from this forum, I am having a difficulty of understanding following,

1. When Singleton instance will be created, ( From which call ) ?

2. What feature of Static Inner class allow object to be singleton ?

3. How Inner Class implementation is thread safe ?

4. What will happen if variable "instance" mark as non-static, Will it still grantee singleton implementation ?

Java Code:

public class Singleton {
// Note private constructor
private Singleton() {}
private static class SingletonInner {
private final static Singleton instance = new Singleton();
}
public static Singleton getInstance() {
return SingletonInner.instance;
}
} mh_sh_highlight_all('java');

View Replies View Related

Obtain Dice As Text Not Numbers

Oct 2, 2014

package dicedemo;
public class DiceDemo {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here

final int Die1_SIDES = 6; // Number of side of dice 1
final int Die2_SIDES = 6; // Number of side of dice 2
// Create two instances of the Die class.

[Code] ....

I need converting the number output to text: example one, two, three, etc.

View Replies View Related

Obtain Server Specifications Based On Application

Jun 19, 2014

a new java executable file which does heavy processing (batch). Development hasn't really started yet and the design phase is just beginning. Now the client is asking us to give them the minimum server specs to be able to run our application..I'm thinking this can't be done without performance testing, which will be after development. Is there a better and faster way to be able to assess this?

View Replies View Related

How To Assign Numbers Obtain From Modular Equation To Certain Position In Array

Apr 16, 2015

My biggest issues are as follows:

1) I'm trying to use a logarithm to determine the length of a user input number. I keep getting an error stating <> indetifier expected. I'm assuming this means that the program is not recognizing the function of a logarithm. I know that normally you can include that information in the method, but my teacher has stated specifically that each of these methods be called something else, as shown in the code.

2) I'm not quite sure I understand how to assign the numbers I obtain from the modular equation to a certain position in the array. As I'm asking the user to input any number these values can change so therefore I can't simply state that first number = this place.Here is my code:

import javax.swing.*;
import javax.*;
public class getSize
{
public static void main( String[] args )

[code]...

View Replies View Related

How Recursion Calls Are Made

Jun 5, 2014

How the recursion works. I tried to figure out writing down low, mid, high at each recursive call. But I seem to be making a mistake somehow. I don't understand where the values are returned to in

if(leftmax>rightmax){
return leftmax;}
else
return rightmax;

Here's the code:

public class Maximum{
public static int max(int[] a,int low,int high){
int mid,leftmax,rightmax;
if(low==high)
return a[low];

[Code] ....

firstly leftmax=max(a,0,4)

Then what is the next line executed?Is it rightmax=max(a,5,8).

After this is it leftmax=max(a,5,6)

rightmax=max(a,7,8)

I tried to understand what these recursion calls by writing them down.But I somehow make a mistake.

View Replies View Related

How To Trace Method Calls

Apr 1, 2015

Consider the two simple Java classes below:

class Computer {
Computer() {
System.out.println("Constructor of Computer class.");
}
void On() {
System.out.println("PC turning on...");

[Code]...

After the program run, how do I trace (1) which object call which method (2) and how many times?

View Replies View Related

Inheritance Method Calls

Jun 25, 2014

If i have 2 classes, Top and ClassB which extends Top

public class Top {
String variable;
public Top(){
setVariable();
}
void setVariable(){
variable = "variable is initialized in Main Class";

[code]....

So what is happening when ClassB inherits from Top?I know that the B constructor is calling super, so does that mean its calling setVariable (in Top?) but as its overridden in ClassB, then that is whats being called and setting the String variable?

View Replies View Related

How To Trace Methods Calls

Mar 31, 2015

Consider the two simple Java classes below:
 
class Computer {
  Computer() {
  System.out.println("Constructor of Computer class.");
  }

[Code]...

After the program run, how do I trace (1) which object call which method (2) and how many times?

View Replies View Related

Trying To Calculate Fine Using Method Calls

Jul 3, 2014

I am trying to calculate a fine in a PoliceOfficer object with method calls to a ParkedCar and ParkingMeter object. The word problem is:

The fine is $25 for the first hour or part of it and $20 for every additional hour of part of it.

My code is:

public class PoliceOfficer
public static final int PARKING_FINE1 = 25;
public static final int PARKING_FINE2 = 20;
public static final int NUMBER_OF_MINUTES_OVER_PARKED = 60;
public double calculateFine(){
double calculateFine = 0;

[Code] ....

obviously the fine is not calculated correctly but I'm not sure how to proceed from here...

View Replies View Related

Encode Getmessage Calls In The Code?

Apr 21, 2015

Im trying to HTML/JavaScript ecode the getmessage calls in the code listed below. The code below is a snippit from a program which is used to handle a failed authentication attempt.

if(logger.isDebugEnabled())
logger.debug("Authentication Failure: " + exception.getMessage());
response.sendError(HttpServletResponse.SC_FORBIDDEN, "Authentication Failed: " + exception.getMessage());

View Replies View Related

Using Consecutive Method Calls On A Single Object

Mar 24, 2014

I don't remember where but I faintly recall one of the oracle docs examples (dealing with GUI basics I think) having something similar to

button.add(lbl).addIcon().addActionListener(al);

but only in the aspect of using .method.method.method

The reason I'm asking is because I want to shorten this

int j = 0;
for(int i = 0; i <= 6; i+=3){
pnl[j+2].add(lbl[i+5]);
pnl[j+2].add(lbl[i+6]);
pnl[j+2].add(drop[j]);
pnl[j+2].add(lbl[i+7]);
pnl[j+2].add(btn[j]);
j++;
}

Into something like this

int j = 0;
for(int i = 0; i <= 6; i+=3){
pnl[j+2].add(lbl[i+5])
.add(lbl[i+6])
.add(drop[j])
.add(lbl[i+7])
.add(btn[j]);
j++;
}

I might be way off though... but I'm just wondering under what circumstances would this be possible

When I try it in Eclipse a little notification appears that says...

"The method add(PopupMenu) in the type Component is not applicable for the arguments (JLabel)"

When I google 'Component' I see it appears to have something to do with Serialization (which I'll need to look into)

View Replies View Related

EJB / EE :: Pass By Reference Not Working Between Remote Calls

Mar 11, 2014

i'm having issues with pass by reference between remote EJB method calls. Below is what i'm trying to do. The EJB method calls are made using remote (EJBObject) interface.

insertEmployeeRecord(Employee employee) {
employeeEJB.insertEmployee(employee);
empDetailsEJB.insertEmpDetails(employee);
}
insertEmployee(Employee employee)

[Code] ....

All the EJBs have below configuration in the weblogic-ejb-jar.xml file.

<enable-call-by-reference>true</enable-call-by-reference>

I'm using Weblogic server 10.3.0.4 and JDK160_21.

View Replies View Related

How To Use JFrame In Child Class - Two Extend Calls

Feb 4, 2014

I am working with a program where I am required to use a JFrame in a child class. The only way that I know how to access a JFrame is to do, example (public class Example extends JFrame), but since it is already extending the parent class, I am kind of stuck. I do not think that you can extend two separate classes, so..... I am stuck.

View Replies View Related

Basic Inheritance And Static Method Calls

Jun 25, 2014

I think its a standard concept but just not getting it. I have 3 classes:

1) Base class
2) Derived class, which extends base
3) TestClass

public class Base {
public void display() {
System.out.println("Display method in Base");
}
}
class Derived extends Base {
public void display() {
System.out.println("display method in Derived");

[Code] .....

So if i run this, my results are:

Display method in Base
display method in Derived
display method in Derived

Thats cool, no problems there, but if i change my Display method in Base and Derived to static methods then the results become:

Display method in Base
display method in Derived
Display method in Base

So why oh why does obj3.display() now print "Display method in Base"?

(and yes I know the calls should be static calls, but for sake of arguments -- or is that the whole problem, that technically obj3.display() is an incorrect call as it can only be Base.display() or Derived.display() when display() is a static method ).

View Replies View Related

Using Method Calls With Returns But It Keeps On Showing Errors

Oct 12, 2014

I am trying to use method calls with returns but it keeps on showing errors. The errors say class, interface, or enum expected. I realize this error occurs if there is issue with declaring class - but i can't seem to find the error. I will post the code that shows error.
 
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.text.*;
public class FuelCost extends JFrame
{
// declarations
Color black = new Color(0, 0, 0);

[Code] ....

The error states:

C:UsersPriti BhattaraiDesktopCCAC JavaFuelCost.java:290: error: ';' expected
public double calculateCostToFillTank()
^
C:UsersPriti BhattaraiDesktopCCAC JavaFuelCost.java:292: error: class, interface, or enum expected
return (averageMilesPerTank / milesPerGallonRating) * currentPricePerGallon;

[Code] ....

12 errors

Tool completed with exit code 1

View Replies View Related

Java Classes - Trace Methods Calls

Apr 1, 2015

Consider the two simple Java classes below:

Java Code:

class Computer {
Computer() {
System.out.println("Constructor of Computer class.");
}
void On() {
System.out.println("PC turning on...");
}
void working() {

[Code] ....

After the program run, how do I trace (1) which object call which method (2) and how many times?

View Replies View Related

Networking :: Intercept All Outgoing HTTP Calls

Dec 12, 2014

Similar to HttpFilter  (javax.Servlet.Filter ) which when added in web.xml can intercept any incoming request to JVM / outgoing (as response) independent of framework ( Spring/CXF/Jersy etc ) without any code changes (excluding the filter itself), I am trying to find an API or approach which could intercept any outgoing HTTP calls from JVM to add/modify headers independent of framework.
 
Quite often the word Outgoing HTTP call is misinterpreted in the forums so let me explain with example.
 
Let us assume there are two JVMs, jvm1 and jvm2. and there are HTTP calls being made from JVM1 to JVM2. I would like to intercept the HTTP connection being made from JVM1 to modify the headers information before the call happens. I do not want the code to be tied to a specific framework so that I can as bundle the interceptor as a jar and share it with application team. Changes in web.xml is fine.

View Replies View Related

JSF :: Display Dialog Upon Session Timeout On Ajax Calls

Feb 19, 2013

I am new to JSF and I am working on handling session timeout for a JSF application. I am trying to get the code to work for ajax calls and not able to achieve that so far. I have tried two approaches:

Approach 1: SessionListener (for cleanup work) and SessionFilter (for filtering every request and checking if session timed out)

My Code snippet of doFilter() of SessionFilter:

if ((request instanceof HttpServletRequest)
&& (response instanceof HttpServletResponse)) {
HttpServletRequest httpServletRequest = (HttpServletRequest) request;
HttpServletResponse httpServletResponse = (HttpServletResponse) response;
// is session expire control required for this request? (not required for home page or timeout page or JSF resources)
if (isSessionControlRequired(httpServletRequest)) {

[Code] .....

Both these approaches work for non-ajax POST calls but not for ajax calls. When I run my app in debug mode, I can step through all the statements for ajax calls also, which gives me an idea that the control does come to my code, executes it but for some reason, nothing happens on the UI.

I have been trying to redirect user to a timeout page but the ideal thing would be to display a JSF dialog and upon hitting 'OK' take user to Home Screen (My app does not have a login screen.) I have a basic questions also, is view expiring exactly same as session timeout?

View Replies View Related

Make A Java Program That Calls Object Value Initialized

Feb 23, 2014

i have this following codes and im trying to make a java program that calls an object value initialized.

public class TestClass
{
public String name;
public int age;
public void myMessage()
{
System.out.println("Hello I'm" + name + "and i'm" + age + "years old");
}
}

what i want is to put the following codes of the object.. so once i compile and run the project it executes the value of an object from the method i defined above.

TestClass myName = new TestClass();
myName.name = "Jefferson";
myName.age = 18;

my question is, it is possible to declare or define it in the same project? or i need to do this separately?

View Replies View Related

Using Synchronized With Static Method Calls Used In Multiple Threads?

Jun 30, 2014

I have a multithreaded application. I have a Logger class with static methods that I use across threads. Would it behoove me to add the synchronized keyword to the static methods of the Logger class since I use this class statically in different threads?

View Replies View Related

Swing/AWT/SWT :: Call Repaint 200 Times In Loop And It Only Calls PaintComponent Once?

Dec 2, 2014

I have been baffled by the functioning of repaint() - and the SwingPaintDemo3 with the moving square seems mysterious - you call repaint(x,y,w,h) twice and the first time it clears the clip area and the 2nd time it paints the red box. The code in paintComponent tells it to paint the box both times, yet somehow it ignores the initial box and only paints the 2nd one.

I've been writing code to bounce some balls in a box to try and understand the behavior. I set up an array of ball objects, loop through them, move them adjusting for collisions with walls and each other, then repaint(). I call repaint x2 for each ball, just like in the example. In my paintComponenet code, if I try to just paint the current ball only one ball will move, even if I send a different ball object each time. The only way to get all the balls to show up is to put a loop in paintComponenet that goes through all 100 balls every time I call it. I was worried that to move 100 balls I was painting 100x100 times.

So I put some System.out.println commands in my ball move loop, inside my object ball draw commands, and inside the paint component.

private void calculateMoveBall(BoxBalls oneBall) {
System.out.printf("
Entering calculateMoveBall [%1$2d]
",

[Code].....

So even though I called repaint() 200 times (twice for each ball), repaint was actually only called once, drew all the balls at once, and then went back. And I just noticed it appears to have waited until I exited the calculateMoveBall loop to go into paintComponent! The spooky things is how does it know to do that? Does the Java machine 'see' that it is inside of a loop, and perhaps also sees the loop inside of paintComponent, and somehow correctly guesses that it doesn't have to do it 200 times, but can wait and do it once? If I attempt to do the same thing in code, take the loop out of paintComponent() and call repaint() with the current ball, expecting the machine to do exactly what I tell it, it refuses and does it's own thing, waiting to call paintComponent on the 100th ball, drawing only the last ball (so I guess the loop inside paintComponent is not in the logic).

So a call to repaint() is a request for a higher being to decide if it has the time or energy to repaint the clip. If not, it ignores the call, or stacks them up for later (maybe I should try a million and see if it has room for that!) - well so far up to 4000 it behaves the same. This is useful if you are happy with "this is how it works so use it that way". However I really don't like having some kind of hidden logic that I have to trust to work the right way. If I don't want it to wait until later I'm not sure what to do. And I don't trust the machine to do whatever whenever. How do you debug that???

Questions: Is there documentation to know what repaint() will do or how it decides when to call paintComponent? The Swing tutorial gives the example but not the why. "By now you know that the paintComponent method is where all of your painting code should be placed. It is true that this method will be invoked when it is time to paint" "An important point worth noting is that although we have invoked repaint twice in a row in the same event handler, Swing is smart enough to take that information and repaint those sections of the screen all in one single paint operation. In other words, Swing will not repaint the component twice in a row, even if that is what the code appears to be doing." (What the code appears to be doing - now we have to guess what it is doing)

Is there a way to force repaint() to call paintComponent on a clip rectangle (not just on the whole thing?) I would think invalidate() would force repainting of the whole componenet.

Perhaps this is when you draw to a bitmap in memory and paint the whole thing on the screen...

View Replies View Related

Altering Parent Method Behavior By Overriding Method It Calls

Apr 21, 2014

I have two classes (Daughter and Son) that contain some very similar method definitions:

public class Family {
public static void main(String[] args) {
Daughter d = new Daughter();
Son s = new Son();
d.speak();
s.speak();

[Code] .....

Each of those classes has a "speak" method with two out of three lines being identical. I could move those into a parent class, but I need each of the child classes to continue to exhibit its unique behavior. I'm trying the approach below, which replaces the unique code with a call to a "placeholder" method that must be implemented by each child class:

public class Family {
public static void main(String[] args) {
Daughter d = new Daughter();
Son s = new Son();

[Code] .....

This works and moves the shared code from two places (the Daughter and Son classes) into one place (the new Mother class, which is now a parent class of Daughter and Son). Something about this feels a bit odd to me, though. It's one thing for a child class to override a parent class's methods to extend or alter their behavior. But, here, I've implemented an abstract method in the parent class to alter what happens when the parent class's method (speak(), in this case) is called, without overriding that parent class method itself.

View Replies View Related

Non-Parameter Constructor Calls Two Parameter Constructor

Apr 19, 2014

I was practicing my java skills and came across an exercise in which a non parameter constructor calls a two parameter constructor. I tried a few searches online but they all came back unsuccessful. This is the part I am working on:

public PairOfDice(int val1, int val2) {
// Constructor. Creates a pair of dice that
// are initially showing the values val1 and val2.
die1 = val1; // Assign specified values
die2 = val2; // to the instance variables.
}
public PairOfDice() {
// Constructor that calls two parameter constructor
}

I tried calling the two constructor using the line "this(val1, val2)" but I get an error because val1 and val2 are local variables.

Then I tried to use the same signature: "this(int val1, int val2)" but that didn't work either.

View Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved