Class of Integer.parseInt
Hi..,
I really need help. I am trying to make a really simple program. And that I want to make an argument class so that I can reuse it again and again without typing the long word (Integer...)
Here is the problem:
Rational r2 = new Rational(toInt(args[0]));
I think I should make a toInt method, but I don't know how. It is quite confusing. I think this toInt method, we should put it inside the main method. But i don't know yet.
Please Help me!
well with the way you wrote it, toInt is a class, not a method. What you are probably envisioning is a class with a constructor which takes a String parameter and returns an int. Unfortunately, constructors don't return values. You can try using the object wrapper class Integer though.
One suggestion, if you hate the typing for getting arg parameters, make a method which takes the whole args array and parses them into a nice int array or some other data structure you dream up to make it easier?
Similar Messages
-
Something's wrong with my Integer.parseInt...
hi...I think something's wrong with my code.
when i don't add the loop for(int s = h; s > 0; s--) { }, it's correct, but when i do, it shows:
java.lang.NumberFormatException: 27.0
at java.lang.Integer.parseInt(Integer.java:414)
at java.lang.Integer.parseInt(Integer.java:454)
at chiayaochien3.evaluate.find(evaluate.java:55)
at chiayaochien3.evaluate.operate(evaluate.java:48)
at chiayaochien3.Main.main(Main.java:10)
Exception in thread "main"
(But i am sure the things in Integer.parseInt is String...)
public class Main
public static void main(String[] args)
String[] data = {"3","+","12","*","27","/","1","-","6", "+", "222"};
String[] operStack = null;
String[] numStack = null;
myStack num1 = new myStack();
myStack num2 = new myStack();
myStack oper1 = new myStack();
myStack oper2 = new myStack();
int calculateNum1 = 0;
int calculateNum2 = 0;
String calculate1 = null;
String calculate2= null;
String oper = null;
double resultNum = 0;
double result = 0;
int operSize = 0;
int numSize = 0;
int h = 0;
for(int i = 0; i < data.length; i++) {
String f = data;
if(f.compareTo("+") == 0)
oper1.push(f);
else if(f.compareTo("-") == 0)
oper1.push(f);
else if(f.compareTo("*") == 0) {
oper1.push(f);
h++;
else if(f.compareTo("/") == 0){
oper1.push(f);
h++;
else if(f.compareTo("^") == 0){
oper1.push(f);
h++;
else
num1.push(f);
}//end of for
for(int s = h; s > 0; s--){
while(!oper1.isEmpty()) {
calculateNum1 = Integer.parseInt((String)num1.pop());
oper = (String)oper1.pop();
if(oper.compareTo("*") == 0) {
calculateNum2 = Integer.parseInt((String)num1.pop());
resultNum = calculateNum2*calculateNum1;
num2.push(String.valueOf(resultNum));
while(oper1.isEmpty() == false && num1.isEmpty() == false) {
oper2.push((String)oper1.pop());
num2.push((String)num1.pop());
}//end of while
}//end of if
else if(oper.compareTo("/") == 0) {
calculateNum2 = Integer.parseInt((String)num1.pop());
resultNum = calculateNum2/calculateNum1;
num2.push(String.valueOf(resultNum));
while(oper1.isEmpty() == false && num1.isEmpty() == false) {
oper2.push((String)oper1.pop());
num2.push((String)num1.pop());
}//end of while
}//end of else-if
else if(oper.compareTo("^") == 0) {
calculateNum2 = Integer.parseInt((String)num1.pop());
resultNum = Math.pow(calculateNum2, calculateNum1);
num2.push(String.valueOf(resultNum));
while(oper1.isEmpty() == false && num1.isEmpty() == false) {
oper2.push((String)oper1.pop());
num2.push((String)num1.pop());
}//end of while
}//end of else-if
else {
num2.push(String.valueOf(calculateNum1));
oper2.push(oper);
}//end of else
}//end of while
while(!oper2.isEmpty()){
oper1.push((String)oper2.pop());
while(!num2.isEmpty()) {
num1.push((String)num2.pop());
while(!num1.isEmpty()) {
System.out.println(num1.pop());
while(!oper1.isEmpty())
System.out.println(oper1.pop());
}//end of main
}//end of class"27.0" is not an integer. (Well, it is numerically, but it's a representation of a double.)
-
Integer.parseInt() error
I am writing an applet that reads a file containing groups of 5 lines of which the first 4 hold a number. Then these values are used to draw circles. When I compile, I get this error message: "incompatible types
found: int, required: java.lang.Integer, ia = Integer.parseInt(a)".
Suggestions?
Thanks!
import java.awt.*;
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import javax.swing.*;
import java.awt.geom.*;
public class Section2 extends Applet {
TextField tekst;
public void init() {
resize(400,400);
tekst = new TextField(20);
add(tekst);
public void paint(Graphics g) {
try {
String a, b, c, d, e;
Integer ia, ib, ic, id;
File inputFile = new File(tekst.getText());
FileReader in = new FileReader(inputFile);
BufferedReader BR = new BufferedReader(in);
while (e != null){
a = BR.readLine();
b = BR.readLine();
c = BR.readLine();
d = BR.readLine();
e = BR.readLine();
ia = Integer.parseInt(a);
ib = Integer.parseInt(b);
ic = Integer.parseInt(c);
id = Integer.parseInt(d);
Graphics2D g2d = (Graphics2D)g;
Ellipse2D.Double circle = new Ellipse2D.Double(ia, ib, ic, id);
g2d.setPaint(Color.blue);
g2d.draw(circle);
in.close();
catch (IOException e) {}Ok everything works! I still have some questions:
*** Can anyone tell me why I get this:
--------------------Configuration: Section2 - j2sdk1.4.0_01 <Default>--------------------
Note: C:\Program Files\Xinox Software\JCreator LE\MyProjects\Section textfield\Section2.java uses or overrides a deprecated API.
Note: Recompile with -deprecation for details.
Process completed.
*** Is there a way to go from string to double in one step?
This is the code:
import java.awt.*;
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import javax.swing.*;
import java.awt.geom.*;
public class Section2 extends Applet {
TextField tekst;
Button knop;
public void init() {
resize(400,400);
tekst = new TextField(20);
add(tekst);
knop = new Button("teken");
add(knop);
public boolean action (Event e, Object o){
if(e.target.equals(knop)){
repaint();
return true;
public void paint(Graphics g) {
try {
String a, b, c, d, e;
Integer ia, ib, ic, id;
File inputFile = new File(tekst.getText());
FileReader in = new FileReader(inputFile);
BufferedReader BR = new BufferedReader(in);
e = "start";
if (tekst.getText() != null){
while (e != null){
a = BR.readLine();
b = BR.readLine();
c = BR.readLine();
d = BR.readLine();
e = BR.readLine();
ia = Integer.valueOf(a);
ib = Integer.valueOf(b);
ic = Integer.valueOf(c);
id = Integer.valueOf(d);
Graphics2D g2d = (Graphics2D)g;
Ellipse2D.Double circle = new Ellipse2D.Double(ia.doubleValue(), ib.doubleValue(), ic.doubleValue(), id.doubleValue());
g2d.setPaint(Color.blue);
g2d.draw(circle);
in.close();
catch (IOException e) {} -
Integer.parseInt problems
Hi everyone,
I want to use the Integer.parseInt and Byte.parseByte methods to parse hex strings - the problem is that they don't parse negative 2's complement numbers, they explicitly need a minus sign in front of an otherwise unsigned number to show that it's negative.
Examples:
//System.out.println(Integer.parseInt(Integer.toHexString(-1), 16)); //NumberFormatException
System.out.println(0xffffffff); // but this prints -1
//System.out.println(Byte.parseByte("ff", 16)); //NumberFormatException
System.out.println(Byte.parseByte("-1", 16)); // but this worksIs there some other method that will do what I need?
Regards,
JonathanHere's a dirty solution:public class Test {
private static char[] digits = new char[] {
'0', '1', '2', '3',
'4', '5', '6', '7',
'8', '9', 'a', 'b',
'c', 'd', 'e', 'f'
public static void main (String[] parameters) {
String number = Integer.toHexString (parameters[0].equals ("+") ? Integer.MAX_VALUE : parameters[0].equals ("-") ? Integer.MIN_VALUE : Integer.parseInt (parameters[0]));
if ((number.length () == 8) && (getPosition (number.charAt (0)) >= 8)) {
String newNumber = "";
for (int i = 0; i < number.length (); i ++) {
newNumber += digits[15 - getPosition (number.charAt (i))];
number = "";
boolean carry = true;
for (int i = 7; i >= 0; i --) {
int position = getPosition (newNumber.charAt (i));
if (carry) {
position = (position + 1) % 16;
carry = (position == 0);
number = digits[position] + number;
number = "-" + number;
int numberAsInt;
try {
numberAsInt = Integer.parseInt (number, 16);
} catch (NumberFormatException exception) {
// -8000000
numberAsInt = Integer.MIN_VALUE;
System.out.println (numberAsInt);
private static int getPosition (char digit) {
int position = 0;
while ((position < digits.length) && (digits[position] != digit)) {
position ++;
return position;
}Start with java Test <yourNumber>: + for Integer.MAX_VALUE, - for Integer.MIN_VALUE.
I don't claim it's good or efficient: it's working though. There's lots of things to improve.
Kind regards,
Levi -
Integer.parseInt()
Hi!
I have a problem that for an experienced programmer like you should be easy.
I have in my program:
int num = Integer.parseInt(numbers);
And I get:
Exception in thread "main" java.lang.NumberFormatException: For input string: "195400011111111111111113"
It (195400011111111111111113) looks like not an integer,and I tried:
long num = Integer.parseInt(numbers);
But I get the same error.
What could I do?
Thank you,
NataThat number is too big for an int, so Integer.parseInt doesn't like it. It doesn't matter if you put a long on the left side of the equals sign, Integer.parseInt only handles ints.
Do you know about the Long class? Have you looked at its docs to see if it might have something that can help you? -
Integer.parseInt, NumberFormatException
Hi,
I'm trying to convert numbers back and forth with parseInt and toHexString.
The number that I want to manipulate is 56789abc.
String str = Integer.toHexString(1450744508);
int i = 0;
try
i = Integer.parseInt(str, 16);
catch(NumberFormatException e)
e.printStackInfo();
I'm not sure why I'm getting NumberFormatException, since I think
56789ABC doesn't cross the line. It's not out of boundary.
Any suggestion or help really be appreciated.
Thanks in advance,I don't know what you're talking about.
Integer.parseInt("56789ABC", 16);gives 1450744508
Works fine. -
Integer.parseInt() method
Hi to all
I'm trying to write a piece of a lexical analizer in Java and I need the method the does the contrary of Integer.parseInt() method in order to do the following:
once i have as input an integer and with the Integer.parseInt() method i know it's value I want to count it's digits. I'm sure there is a method that do the contrary of Integer.parseInt() method that I can't remeber.
Thanks for your help
MaddyInteger.parseInt() takes in a String and returns an int value, so the contrary would take in an int value and return a String. Is this what you want?
You can use Integer.toString()
Also, when you call Integer.parseInt(String s), you should already have the number as a String (the argument).
Maybe I am not understanding the question right. If not, please explain exactly what you need. -
String equivalent of Integer.parseInt()
Hey..
Integer.parseInt() reads an integer that is being inputted right? what im looking though is some sort of a String equivalent of Integer.parseInt.
ex:
nString = JOptionPane.showInputDialog("Enter number:");
n = Integer.parseInt(nString);
what im looking:
nString = JOptionPane.showInputDialog("Enter text:");
n = ? (nString);
a keyword that reads the text inputted.how do i reset the counter to 0 if the user tries again? because it doesn't reset and it makes a logical error if the user tries again.
while (trya != 0){
if ((trya > 1) || (trya < 0))
break;
else{
z=JOptionPane.showInputDialog("Choose Difficulty:\n[1]BATHROOM SINGER\n[2]MAINSTREAM MUSICIAN\n[3]GRAMMY WINNER");
x=Integer.parseInt(z);
switch(x){
case 1:
JOptionPane.showMessageDialog(null,"DIFFICULTY: BATHROOM SINGER");
String stringInput = JOptionPane.showInputDialog(q1);
if (stringInput.equals(a1)){
JOptionPane.showMessageDialog(null, "Correct!");
i++;
} else {
j++;
JOptionPane.showMessageDialog(null,"Wrong");
String stringInput29 = JOptionPane.showInputDialog(q15);
if (stringInput29.equals(a15)){
JOptionPane.showMessageDialog(null, "Correct!");
i++;
} else {
j++;
JOptionPane.showMessageDialog(null,"Wrong");
JOptionPane.showMessageDialog(null,"Correct answers: "+i+"\nWrong answers: "+j+"\nTHANKS FOR PLAYING");
break;
default:
JOptionPane.showMessageDialog(null,"Press either [1] [2] or [3]", "ERROR",JOptionPane.WARNING_MESSAGE);
break;
stry = JOptionPane.showInputDialog("Do you want to PLAY AGAIN? \n Press [1] for YES \n Press [0] for NO");
trya = Integer.parseInt(stry);
} -
Hi,
There is a new feature added in java 7 on integer, called as underscore '_" and it is working fine
if it is a normal int variable but if it is coming with String jvm throw the error.
if any one of you have java8 installed on your PC can you check this is working on that version.
int a = 1000_000;
String strNum = "1000_000";
// System.out.println("..abc..."+ Integer.parseInt(strNum));
System.out.println("a..."+a);
Thank you,
Shailesh.what is your actual question here?
bye
TPD -
Integer.parseInt(in.readLine()) - "null"
I just realized that if I don't enter a value in the following:
System.out.print("Enter the column you'd like to mark in: ");
int col = Integer.parseInt(in.readLine());I get this error:
Enter the column you'd like to mark in:
java.lang.NumberFormatException: For input string: ""
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
at java.lang.Integer.parseInt(Integer.java:447)
at java.lang.Integer.parseInt(Integer.java:476)
at la5.TicTacToeDriver.main(TicTacToeDriver.java:37)
Exception in thread "main" Is there a way to prevent this error and prompt the user for a proper input (any integer will work).Enclose the parse attempt in a try/catch block.
-
NetBeans 6.5 - Integer.parseInt(String)
Hello,
I'm beginner with NetBeans 6.5.
I created a simple hello-java application and a simple hello java-web JSF application.
I have no error with hello-java application for these 2 lines:
String name = "12345";
int aInt = Interger.parseInt(name) ;
but I get exception handler from java-web JSF application as below.
Hope you help me to solve this, Thanks !
Exception Handler
Description: An unhandled exception occurred during the execution of the web application. Please review the following stack trace for more information regarding the error.
Exception Details: java.lang.NumberFormatException
null
Possible Source of Error:
Class Name: java.lang.Integer
File Name: Integer.java
Method Name: parseInt
Line Number: 415
Source not available. Information regarding the location of the exception can be identified using the exception stack trace below.
......they're different, i was trying to convert the string entered in a TextField to a number, and thought that I already hard coded '12345' in the code to see whether the parseInt works therefore i didn't enter anything in the TextField.
thanks raychen ! -
Is there any way to use Integer.parseInt using jstl
Hi
actually i m getting a string in a varible i need to convert it to int so that i can use it for further calculation.
so plz tell how to do that...
thanksThe exception clearly states the variable isn't a valid number. Print out the value and see what it is.
And no, you can't set the 'JSTL variable' for the simple reason that there are no 'JSTL variables' ( at least none that are public ). You're probably thinking of the EL. And no, you can't do anything there either.
People on the forum help others voluntarily, it's not their job.
Help them help you.
Learn how to ask questions first: http://faq.javaranch.com/java/HowToAskQuestionsOnJavaRanch
(Yes I know it's on JavaRanch but I think it applies everywhere)
---------------------------------------------------------------- -
Help with creating a method within a class
I need help creating another method within the same class.
Here is part of my progam, and could anyone help me convert the switch statement into a seperate
method within the same class?
import javax.swing.JOptionPane;
public class Yahtzee
public static void main (String[] args)
String numStr, playerStr, str, tobenamed;
int num, times = 13, roll, x, y, maxRoll = 3, z = 0, t;
int firstDie, secondDie, thirdDie, fourthDie, fifthDie, maxDie = 5, reroll;
int rerolling = 0, categoryChoice, score, nextDie1, nextDie2, nextDie3, nextDie4;
Die die1, die2, die3, die4, die5;
do
numStr = JOptionPane.showInputDialog ("Enter the number of player: ");
num = Integer.parseInt(numStr);
while (num < 1 || num > 6); //end of do loop
String [] player = new String[num];
// boolean //finsih later to make category choice only once.
for (x = 0; x < num; x++)
playerStr = JOptionPane.showInputDialog ("Name of Player" + (x + 1) + " :");
player[x] = playerStr;
} //end of for loop
die1 = new Die();
die2 = new Die();
die3 = new Die();
die4 = new Die();
die5 = new Die();
int scoring [][] = new int [num][13];//scoring aray
int[] numDie = new int[maxDie];
String[][] usedCategory = new String [num][times];
for (x=0; x < 13; x++)
for (y = 0; y < num; y++)
usedCategory[y][x] = " ";
for (int choices = 0; choices < times; choices++)
//player turns for loop.
for (x = 0; x < num; x++)
//rolls the die;
for (y = 0; y < maxDie; y++)
numDie[y] = die1.roll();
numStr = JOptionPane.showInputDialog (player[x] + "\n~~~~~~~~~~~~~~~~~~~~~~~"
+ "\nDie1: " + numDie[0]
+ "\nDie2: " + numDie[1]
+ "\nDie3: " + numDie[2]
+ "\nDie4: " + numDie[3]
+ "\nDie5: " + numDie[4]
+ "\nWhich dice do you want to reroll");
reroll = numStr.length();
if (reroll == 0)
t = maxRoll;
else{
//reroll
for(t = 0; t < maxRoll; t++ )
for (y = 0; y < reroll; y++)
rerolling = numStr.charAt(y);
//create another mwthod later.
switch (rerolling)
case '1':
numDie[0] = die1.roll();
break;
case '2':
numDie[1] = die1.roll();
break;
case '3':
numDie[2] = die1.roll();
break;
case '4':
numDie[3] = die1.roll();
break;
case '5':
numDie[4] = die1.roll();
break;
default:
t = maxRoll;//to be changed
} //end of switch class
}//end of reroll for loop
JOptionPane.showMessegeDialog (player[x] + "\n~~~~~~~~~~~~~~~~~~~~~~~"
+ "\nDie1: " + numDie[0]
+ "\nDie2: " + numDie[1]
+ "\nDie3: " + numDie[2]
+ "\nDie4: " + numDie[3]
+ "\nDie5: " + numDie[4]
+ "\nWhich dice do you want to reroll"
switch (rerolling)
case '1':
numDie[0] = die1.roll();
break;
case '2':
numDie[1] = die1.roll();
break;
case '3':
numDie[2] = die1.roll();
break;
case '4':
numDie[3] = die1.roll();
break;
case '5':
numDie[4] = die1.roll();
break;
default:
t = maxRoll; //not really anything yet, or is it?
} //end of rerolling switch class
//categorychoice = Integer.parseInt(category);
}//end of t for loop
}//end of player for loop.samuraiexe wrote:
well, i should have said it is a yahtzee program, and i ask the user what they want to reroll and whatever number they press, the switch will activate the case and the array that it will reroll.
HOw would i pass it as an argument?You put it in the argument list. Modifying your original code a bit:
public static void switchReroll (int[] dice, int position) {
switch (position) {
case '1':
dice[0] = die1.roll()
break;
case '2':
dice[1] = die1.roll();
break;
case '3':
dice[2] = die1.roll();
break;
case '4':
dice[3] = die1.roll();
break;
case '5':
dice[4] = die1.roll();
break;
default:
t = maxRoll;//to be changed
} //end of switch
}which you could then call as this:
switchReroll(numDie, reroll);Note that your code still isn't done; the above won't compile. This is just an example of how you could pass the stuff as an argument (and note how the values have different names in the main method than in the switchReroll method -- this works, but also note that it's the same array of ints in both).
By the way -- you really don't need a switch statement for this. You can do the same thing with a couple lines of code, which would lessen the advantage for a separate method. But I'd suggest continuing down this path, and then you could change the implementation of the method later. -
URGENT timout problems with bc4j
Hello Jdev Team,
We have a serious problem with the BC4J. The situation is as
follows:
We use BC4J with jsp pages an run the whole thing on a j2ee
Container.
We have written our own ApplicationPool class and
ApplicationModule datatag because the users have to login
using different credentials. The login users are db-users. The
application release mode is reserved.
The application crashes frequently. 2 errors occur.
First of all we get an JBO-30003: "The application pool, {AM
Name}, failed to checkout an application module instance."
after the BC4J Container timeout --> messages ("BC4J HTTP
Container was timed out" and "The binding listener for { AM
name} was timed out")
We haven't found a way to alter the BC4J container timeout.
Where do we customize the timeout?
We have tried to use the HttpSessionTimeOut variable but it
seems to have no effect.
I hope you can help us with this one.
Second problem is that the J2EE Container stops functioning
after a couple of requests.
Even if an other browser is started (on the same or different
machine) the Container does not respond to any request.
We have found a Thread on technet handling this kind of problem
but the solution doesn't work in our case.
(the solution on technet was to put synchronized(session) around
each JSP page)
Now we run the application under Apache/Jserv and with the same
Runtime packages as used in the Container and the problem
seems to have disappeared.
Here follows the code of the ApplicationPool class:
The class is based on an example posted on technet
* @author Juan Oropeza
package be.cronos.dbwise.jbo;
import oracle.jbo.common.ampool.ApplicationPoolImpl;
import oracle.jbo.ApplicationModule;
import java.util.Properties;
public class SeperateLoginApplicationPool extends
ApplicationPoolImpl
private String vConnectURL;
private String vUsername;
private String vPassword;
public SeperateLoginApplicationPool()
public void setConnectInfo(String pUsername, String pPassword,
String pConnectURL)
this.vUsername = pUsername;
this.vPassword = pPassword;
this.vConnectURL = pConnectURL;
protected void connect(ApplicationModule appModule)
if (!appModule.getTransaction().isConnected())
appModule.getTransaction().connect(vConnectURL ,
vUsername, vPassword);
//use Optimistic locking as default for all transactions
appModule.getTransaction().setLockingMode
(oracle.jbo.Transaction.LOCK_OPTIMISTIC);
* checkin
* @param appModule
public synchronized void checkin(ApplicationModule appModule)
// release the instance regardless of the release mode
// this is necessary since we need a fresh instance each
time.
this.releaseInstance(appModule);
this.releaseInstances();
public void disconnect(ApplicationModule pAppModule, boolean
pRetainState)
super.disconnect(pAppModule, pRetainState);
Here is the code of the applicationPool datatag:
* @author Juan Oropeza
* @author Ief Cuynen
* @version 1.1
/* Modification history
package be.cronos.dbwise.datatags;
import be.cronos.dbwise.jbo.SeperateLoginApplicationPool;
import javax.servlet.jsp.tagext.TagSupport;
import javax.servlet.jsp.JspException;
import java.io.StringWriter;
import java.io.PrintWriter;
import oracle.jbo.html.jsp.ConnectionInfo;
import oracle.jbo.common.ampool.PoolMgr;
import oracle.jbo.common.ampool.ApplicationPool;
import oracle.jbo.ApplicationModule;
import oracle.jbo.html.jsp.JSPApplicationRegistry;
import java.util.Properties;
import java.util.Hashtable;
import java.util.Enumeration;
public class ApplicationModuleTag extends TagSupport
String fApplicationName;
String fConfigName;
String fUsername;
String fPassword;
String fConnectionURL;
String fIiopUserName;
String fIiopPassword;
JSPApplicationRegistry fAppRegistry;
public ApplicationModuleTag()
public void setId(String pAppName)
{ this.fApplicationName = pAppName; }
public void setConfigname(String pValue)
{ this.fConfigName = pValue; }
* doEndTag
* @return int
* @exception javax.servlet.jsp.JspException
public int doEndTag() throws JspException
try
SeperateLoginApplicationPool pool = null;
init();
// Get an application module resource.
fAppRegistry = JSPApplicationRegistry.getInstance();
// this step will access the custom pool from the property
file
appRegistry.registerApplicationFromPropertyFile
(fApplicationName);
// Since we don't want to use a
PropertyFile per AM, we have written are own
registerApplicationModule method
this.registerApplicationModule();
// get an instance of the pool, which is already existing
pool = (SeperateLoginApplicationPool)
PoolMgr.getInstance().getPool(fApplicationName);
// get an instance of the application module
synchronized(pool)
// Setup the connection information
pool.setConnectInfo(fUsername, fPassword,
fConnectionURL);
// This instance will be used by the rest of the
DataWebBeans since it’s part of the context.
try
//After the BC4J
container timeout, this method will raise an exception
ApplicationModule am =
fAppRegistry.getAppModuleInstance(fApplicationName, pageContext);
catch(Exception e)
System.out.println
("JspRegistry has failed to get application module instance");
setPageContextValues();
catch(Exception ex)
StringWriter writer = new StringWriter();
PrintWriter prn = new PrintWriter(writer);
ex.printStackTrace(prn);
prn.flush();
throw new JspException(writer.toString());
return SKIP_BODY;
* for internal use only
private void init()
fUsername = (String)pageContext.getSession().getValue
("username");
fPassword = (String)pageContext.getSession().getValue
("password");
fConnectionURL = (String)pageContext.getSession().getValue
("connectionURL");
private void setPageContextValues()
// place default renderers into session, these will not be
exposed via config file
pageContext.getSession().putValue
("oracle_ord_im_OrdImageDomain_Renderer", "oracle.ord.html.OrdBui
ldURL");
pageContext.getSession().putValue
("oracle_ord_im_OrdAudioDomain_Renderer","oracle.ord.html.OrdBuil
dURL");
pageContext.getSession().putValue
("oracle_ord_im_OrdVideoDomain_Renderer","oracle.ord.html.OrdBuil
dURL");
pageContext.getSession().putValue
("oracle_ord_im_OrdVirDomain_Renderer", "oracle.ord.html.OrdBuild
URL");
pageContext.getSession().putValue
("oracle_ord_im_OrdImageDomain_EditRenderer", "oracle.ord.html.Fi
leUploadField");
pageContext.getSession().putValue
("oracle_ord_im_OrdAudioDomain_EditRenderer", "oracle.ord.html.Fi
leUploadField");
pageContext.getSession().putValue
("oracle_ord_im_OrdVideoDomain_EditRenderer", "oracle.ord.html.Fi
leUploadField");
pageContext.getSession().putValue
("oracle_ord_im_OrdVirDomain_EditRenderer", "oracle.ord.html.File
UploadField");
protected synchronized void registerApplicationModule()
PoolMgr vPoolMgr = PoolMgr.getInstance();
try
if (!vPoolMgr.isPoolCreated(fApplicationName))
// Parse the ConfigName
String vConfigPackage =
fConfigName.substring(0, fConfigName.lastIndexOf('.'));
String vConfigSection = fConfigName.substring
(fConfigName.lastIndexOf('.') + 1);
//Strip out the AM Class
vConfigPackage =
vConfigPackage.substring(0, vConfigPackage.lastIndexOf('.'));
Properties vProps = new Properties();
vProps.put("ConfigName",fConfigName);
ApplicationPool vAppPool =
vPoolMgr.createPool(fApplicationName,vConfigPackage,
vConfigSection, vProps);
vAppPool.setUserName
(this.fUsername);
vAppPool.setPassword
(this.fPassword);
catch (Exception ex)
ex.printStackTrace();
throw new RuntimeException(ex.toString
* release() called after doEndTag() to reset state
public void release()
super.release();
fApplicationName = null;
fConfigName = null;
fUsername = null;
fPassword = null;
fConnectionURL = null;
fIiopUserName = null;
fIiopPassword = null;
JSPApplicationRegistry fAppRegistry = null;
Another thing is that the JSPApplicationRegistry contains a bug
(I think)
It doesn't use the HttpSessionTimeOut variable at all (see
following code)
this piece of code is a Method from the
JSPApplicationRegistry.java File taken from package
oracle.jbo.html.jsp;
static synchronized public void
registerApplicationFromPropertyFile(HttpSession session, String
sPropFileName)
if(!mPoolManager.isPoolCreated(sPropFileName))
registerApplicationFromPropertyFile(sPropFileName);
if (!PropertyConstants.TRUE.equals((String)session.getValue
(SESSION_INITIALIZED)))
Hashtable settings = getAppSettings(sPropFileName);
/* The timeout variable is declared here */
int nTimeOut = 300;
if (settings != null)
// see if we have a setting for the session timeout
String sTimeOut;
/* get the HttpSessionTimeOut variable */
if(settings.get("HttpSessionTimeOut") != null)
sTimeOut = (String)settings.get
("HttpSessionTimeOut");
if(sTimeOut != null)
/* Put the value in the variable... and that's the last thing it
does. nTimeOut isn't used anywhere in the class */
nTimeOut = Integer.parseInt(sTimeOut);
if(settings.get("ImageBase") != null)
session.putValue("ImageBase", settings.get
("ImageBase"));
else
settings.put("ImageBase", "/webapp/images");
session.putValue("ImageBase", "/webapp/images");
if(settings.get("CSSURL") != null)
session.putValue("CSSURL",settings.get("CSSURL"));
else
settings.put("CSSURL", "/webapp/css/oracle.css");
session.putValue
("CSSURL", "/webapp/css/oracle.css");
// place default renderers into session, these will not
be
// exposed via config file
session.putValue
("oracle_ord_im_OrdImageDomain_Renderer", "oracle.ord.html.OrdBui
ldURL");
session.putValue
("oracle_ord_im_OrdAudioDomain_Renderer","oracle.ord.html.OrdBuil
dURL");
session.putValue
("oracle_ord_im_OrdVideoDomain_Renderer","oracle.ord.html.OrdBuil
dURL");
session.putValue
("oracle_ord_im_OrdVirDomain_Renderer", "oracle.ord.html.OrdBuild
URL");
session.putValue
("oracle_ord_im_OrdImageDomain_EditRenderer", "oracle.ord.html.F
ileUploadField");
session.putValue
("oracle_ord_im_OrdAudioDomain_EditRenderer", "oracle.ord.html.F
ileUploadField");
session.putValue
("oracle_ord_im_OrdVideoDomain_EditRenderer", "oracle.ord.html.F
ileUploadField");
session.putValue
("oracle_ord_im_OrdVirDomain_EditRenderer", "oracle.ord.html.F
ileUploadField");
session.putValue(SESSION_INITIALIZED,
PropertyConstants.TRUE);
Am I mistaken or is it a bug?
Thank you for your fast response.
Greetings,
Ief CuynenFirst of all we get an JBO-30003: "The application pool, {AM Name}, failed to checkout an application module
instance."
The JBO-30003 exception is thrown whenever the pool cannot
properly create/recycle an application module. Please see the
exception details (scan the exception stack to find the exception
details) for more information regarding the "root" cause of the
exception.
We haven't found a way to alter the BC4J container timeout. Where do we customize the timeout?
The BC4J container is timed out when the HttpSession is timed
out. The session timeout is configurable via the web.xml file
for the J2EE application. Your servlet container may also
include another mechanism for setting a session timeout.
Second problem is that the J2EE Container stops functioning after a couple of requests. Even if an other browser
is started (on the same or different machine) the Container does
not respond to any request. We have found a Thread on technet
handling this kind of problem but the solution doesn't work in
our case.
The issue sounds like a deadlock. Please use kill -3 (Solaris)
or ctrl-break (NT) at the java server console to print the thread
stack trace to stdout. This will contain more information
regarding which threads are blocked and where. If you would like
you can send the stack trace to me via mail and I can take a look
at it.
The solution of synchronizing your pages with the HttpSession
context is required only if you are using the BC4J datatags with
HTML frames (i.e. have multi-threaded application module
access for a given session). Please note that this solution may
have a performance impact and should not be implemented unless
absolutely necessary.
Another thing is that the JSPApplicationRegistry contains a bug (I think). It doesn't use the HttpSessionTimeOut variable
at all (see following code)
This parameter was deprecated after 3.1. It looks like the code
which used the parameter may have been removed prematurely.
Sorry for the confusion. Please use the J2EE compliant
mechanisms mentioned above to configure the session timeout in
3.2.
Finally, please note that JDeveloper9i includes new integrated
features for the often requested feature of supporting different
db users with the same application pool! Please stay tuned. -
PLEAS help opening a frame when clicking a button
i have a applet and when i click on a button it opens a frame. i have atried a couple of things but the frame does not open. Can anybody Please help
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class mainscreen1 extends Applet implements ItemListener, ActionListener
private Image layout1;
private int frame;
private int xpos,ypos,xdir,ydir;
public TextField tn, tt1, tt2, total;
public int value, ticketnum, sum;
public Label title, seat, need, payable;
public Button b1, b2;
Mydialog1 d;
public void init()
setBackground(Color.pink);
setSize (600, 460);
setLayout(null);
xpos = getSize().width/-1400;
ypos = getSize().height/12;
layout1 = getImage(getDocumentBase(),"layout1.gif");
title=new Label("Almeida Theater booking system");
title.setBounds(150,0,185,30);
add(title);
seat=new Label("Please choose a seating location:");
seat.setBounds(300,40,190,25);
add(seat);
payable=new Label("Total Payable:�");
payable.setBounds(300,390,100,30);
add(payable);
need=new Label("Please enter the number of seats needed:");
need.setBounds(300,180,245,30);
add(need);
CheckboxGroup radio = new CheckboxGroup();
Checkbox Stalls = new Checkbox("Stalls", true, radio);
Stalls.setBounds(490,40,60,25);
add(Stalls);
Stalls.addItemListener(this);
Checkbox Balcony = new Checkbox("Balcony", false, radio);
Balcony.setBounds(490,65,65,25);
add(Balcony);
Balcony.addItemListener(this);
Checkbox Concessions = new Checkbox("Concessions", false, radio);
Concessions.setBounds(490,90,94,25);
add(Concessions);
Concessions.addItemListener(this);
Button b1=new Button("Quote");
b1.setBounds(20,395,80,30);
add(b1);
b1.addActionListener( this );
Button b2=new Button("Confirm booking");
b2.setBounds(110,395,100,30);
add(b2);
b2.addActionListener( this );
tt1=new TextField(60);
tt1.setBounds(300,250,270,30);
add(tt1);
tt1.addActionListener(this);
tt2=new TextField(60);
tt2.setBounds(300,300,150,30);
add(tt2);
tt2.addActionListener(this);
tn=new TextField(3);
tn.setBounds(545,180,30,30);
add(tn);
tn.addActionListener(this);
total=new TextField(5);
total.setBounds(400,390,45,30);
add(total);
total.addActionListener(this);
public void itemStateChanged(ItemEvent e)
String c1 = (String) e.getItem();
if (c1 == "Stalls")
value = 20;
else if (c1 == "Balcony")
value = 15;
else
value = 10;
tt1.setText("You have chosen to sit in the " + c1 + " area");
tt2.setText("Each seat will cost: �" + value);
repaint();
public void actionPerformed ( ActionEvent e )
if( e.getActionCommand() == "Quote" )
//String sum = (String) e.getItem();
//sum = value*ticketnum;
//Ssumtotal
//total.setText(sum);
else if( e.getActionCommand() == "Confirm booking")
d = new Mydialog1(new Frame());
ticketnum = Integer.parseInt(tn.getText());
repaint();
public void paint(Graphics g)
g.setColor(Color.black);
g.drawString ("You have chosen:" + ticketnum +" seats", 300, 365);
g.drawImage(layout1,xpos,ypos,null);
Above is the 1st screen and when i click
confirm booking it don't open the frame, which is below:
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class Mydialog1 extends Frame implements ActionListener
public Label title;
public Button b1, b2;
public void init()
setBackground(Color.pink);
setSize (600, 460);
setLayout(null);
setLocation(320,140);
setVisible(true);
Mydialog1(Frame f);
title=new Label("Almeida Theater booking system");
title.setBounds(150,0,185,30);
add(title);
Button b1=new Button("Close");
b1.setBounds(20,395,80,30);
add(b1);
b1.addActionListener( this );
Button b2=new Button("Proced with booking");
b2.setBounds(110,395,100,30);
add(b2);
b2.addActionListener( this );
public void actionPerformed( ActionEvent e )
if( e.getActionCommand() == "Close" )
this.dispose();
else if( e.getActionCommand() == "Proced with booking")
setBackground(Color.blue);
Can anyone help also can anyone explain how i do calcualtions on the mainscreen.calss. the bit that says Quote. it has // cos i canot get it to work
PLEASE PLEASEno, you dont have to create a new class.
here is your own code. This time we pass the parameters to another method, and
not the constructor.
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class mainscreen1 extends Applet implements ItemListener, ActionListener
private Image layout1;
private int frame;
private int xpos,ypos,xdir,ydir;
public TextField tn, tt1, tt2, total;
public int value, ticketnum, sum;
public Label title, seat, need, payable;
public Button b1, b2;
Mydialog1 d;
String c1; // obs
public void init()
setBackground(Color.pink);
setSize (600, 460);
setLayout(null);
xpos = getSize().width/-1400;
ypos = getSize().height/12;
layout1 = getImage(getDocumentBase(),"layout1.gif");
title=new Label("Almeida Theater booking system");
title.setBounds(150,0,185,30);
add(title);
seat=new Label("Please choose a seating location:");
seat.setBounds(300,40,190,25);
add(seat);
payable=new Label("Total Payable:�");
payable.setBounds(300,390,100,30);
add(payable);
need=new Label("Please enter the number of seats needed:");
need.setBounds(300,180,245,30);
add(need);
CheckboxGroup radio = new CheckboxGroup();
Checkbox Stalls = new Checkbox("Stalls", true, radio);
Stalls.setBounds(490,40,60,25);
add(Stalls);
Stalls.addItemListener(this);
Checkbox Balcony = new Checkbox("Balcony", false, radio);
Balcony.setBounds(490,65,65,25);
add(Balcony);
Balcony.addItemListener(this);
Checkbox Concessions = new Checkbox("Concessions", false, radio);
Concessions.setBounds(490,90,94,25);
add(Concessions);
Concessions.addItemListener(this);
Button b1=new Button("Quote");
b1.setBounds(20,395,80,30);
add(b1);
b1.addActionListener( this );
Button b2=new Button("Confirm booking");
b2.setBounds(110,395,100,30);
add(b2);
b2.addActionListener( this );
tt1=new TextField(60);
tt1.setBounds(300,250,270,30);
add(tt1);
tt1.addActionListener(this);
tt2=new TextField(60);
tt2.setBounds(300,300,150,30);
add(tt2);
tt2.addActionListener(this);
tn=new TextField(3);
tn.setBounds(545,180,30,30);
add(tn);
tn.addActionListener(this);
total=new TextField(5);
total.setBounds(400,390,45,30);
add(total);
total.addActionListener(this);
public void itemStateChanged(ItemEvent e)
c1 = (String) e.getItem();
if (c1 == "Stalls")
value = 20;
else if (c1 == "Balcony")
value = 15;
else
value = 10;
tt1.setText("You have chosen to sit in the " + c1 + " area");
tt2.setText("Each seat will cost: �" + value);
repaint();
public void actionPerformed ( ActionEvent e )
if( e.getActionCommand() == "Quote" )
//String sum = (String) e.getItem();
//sum = value*ticketnum;
//Ssumtotal
//total.setText(sum);
else if( e.getActionCommand() == "Confirm booking")
int nr_seats = Integer.parseInt(tn.getText());
total.setText("" +nr_seats*value);
d = new Mydialog1();
d.set_text(c1, nr_seats); // pass the c1 and the nr_seats vriables to the
// set_text method in the Mydialog1 class.
ticketnum = Integer.parseInt(tn.getText());
repaint();
public void paint(Graphics g)
g.setColor(Color.black);
g.drawString ("You have chosen:" + ticketnum +" seats", 300, 365);
g.drawImage(layout1,xpos,ypos,null);
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class Mydialog1 extends Frame implements ActionListener
public Label title;
public Button b1, b2;
TextField tf; ///***/
public Mydialog1()
setBackground(Color.pink);
setSize (600, 460);
setLayout(null);
setLocation(320,140);
//Mydialog1(Frame f);
title=new Label("Almeida Theater booking system");
title.setBounds(150,0,185,30);
add(title);
Button b1=new Button("Close");
b1.setBounds(20,395,80,30);
add(b1);
b1.addActionListener( this );
Button b2=new Button("Proced with booking");
b2.setBounds(110,395,100,30);
add(b2);
b2.addActionListener( this );
tf = new TextField(); //new
tf.setBounds(230, 395, 100,30); //new
add(tf); //new
setVisible(true);
public void actionPerformed( ActionEvent e )
if( e.getActionCommand() == "Close" )
this.dispose();
else if( e.getActionCommand() == "Proced with booking")
setBackground(Color.blue);
* Folowing method can take two parameters. One string and one int.
public void set_text ( String seat_type, int nr_seats )
tf.setText (seat_type +". " +nr_seats);
}
Maybe you are looking for
-
Splitting data in one row and inserting into seperate rows into a new table
i have a table table1 like the following column1 column2 column3 a b,cbdm,d hj ba hello man i have to insert data from this table to table2 in the following format Column1 column2 column3 a
-
Itunes store link not working PLEASE HELP!
I can't connect to the itnues music store and get the following error message when I try: itunes could not connect to the Music Store. The network connection was reset. Make sure your network connection is active and try again. If anyone could give m
-
Time Machine Backup Disk Cannot be found
While my iMac was in sleep mode, I disconnected the power to my external, firewire time machine backup disk. The backup is a Western Digital hard drive. Now I get the error message "Your Time Machine Backup Disk Cannot be Found" I have rebooted the c
-
In which table the link between the R/3 vendor and SRM vendor no are found?
Hi experts, Can anay one tell me in which table exactly where we can find the relation between the R/3 vendors who are replicated to SRM and material groups which are replicated to SRM. I just want to know th backend number and the frontend Number of
-
My new mail notification red bubble won't pop-up in my dock?
Why doesn't the red bubble with the number of new messages in my Mail Inbox pop-up in my dock on the Mail Icon when I get new messages?