How can i apply this java program for a jsp page?
import java.io.*;
import java.util.*;
public class FileProcessing
//create a vector container for the input variables
Vector variables = new Vector();
//create a vector container for the constants
Vector constants = new Vector();
/*create a string expression container for the equation
as read from the file */
String expression = " ";
//create double result container for the final result
double result = 0;
public boolean processFile(String filename,String delim)
//index for values vector
int num_values = 0;
//index for constants vector
int num_constants = 0;
//current line being read from the external file.
String curline = " ";
//start reading from the external file
try
FileReader fr = new FileReader(filename);
BufferedReader br = new BufferedReader(fr);
while(true)
curline = br.readLine();
if(curline == null)
break;
//determine the type of current interaction
boolean variable = curline.startsWith("input");
boolean constant = curline.startsWith("constant");
boolean equation = curline.startsWith("equation");
boolean output = curline.startsWith("result");
//on input variables
if(variable)
StringTokenizer st = new StringTokenizer(curline,delim);
int num = st.countTokens();
int count=0;
while(st.hasMoreTokens())
String temp = st.nextToken();
if(count==1)
byte b[]= new byte[100];
System.out.println(temp);
System.in.read(b);
String inputval = (new String(b)).trim();
variables.add(num_values,inputval);
num_values++;
count++;
// on constant values
if(constant)
StringTokenizer st = new StringTokenizer(curline,delim);
int num = st.countTokens();
int count = 0;
while(st.hasMoreTokens())
String temp = st.nextToken();
if(count==1)
byte b[]= new byte[100];
System.out.println(temp);
System.in.read(b);
String cons = (new String(b)).trim();
constants.add(num_constants,cons);
num_constants++;
count++;
// on equation
if(equation)
StringTokenizer st = new StringTokenizer(curline,delim);
int num = st.countTokens();
int count = 0;
while(st.hasMoreTokens())
String temp = st.nextToken();
if(count==2)
this.expression = temp;
count++;
// now we are ready to evaluate the expression
if(output)
org.nfunk.jep.JEP myparser= new org.nfunk.jep.JEP();
myparser.setAllowAssignment(true);
for(int i=1;i<variables.size()+1;i++)
String name = "arg"+Integer.toString(i);
myparser.addVariable(name,new Double(variables.get(i-1)
.toString()).doubleValue());
for(int i=1;i<constants.size()+1;i++)
String name = "arg" +Integer.
toString(i+variables.size());
myparser.addConstant(name,new Double(constants.get(i-1).toString()));
//output is obtained as follows
myparser.parseExpression(expression);
result = myparser.getValue();
System.out.println("Assay value: "+result);
catch(Exception e)
System.out.println(e.toString());
return true;
public static void main(String[] args)
FileProcessing fp = new FileProcessing();
fp.processFile("input.eqn",":");
}//my text file name is: "input.eqn" (given below)
input:Enter Value1:arg1
input:Enter Value2:arg2
input:Enter Value3:arg3
constant:arg4
constant:arg5
Equation:arg1+arg2+arg3
result:
how can i apply this java program for a jsp pagewhy do you want to do this ?
Your program reads from a file on the disk and formats based on a patterm.
Jsp is not intended for such stuff.
ram.
Similar Messages
-
How can i use this java program to access from a jsp page?
import java.io.*;
import java.util.*;
public class FileProcessing
//create a vector container for the input variables
Vector variables = new Vector();
//create a vector container for the constants
Vector constants = new Vector();
/*create a string expression container for the equation
as read from the file */
String expression = " ";
//create double result container for the final result
double result = 0;
public boolean processFile(String filename,String delim)
//index for values vector
int num_values = 0;
//index for constants vector
int num_constants = 0;
//current line being read from the external file.
String curline = " ";
//start reading from the external file
try
FileReader fr = new FileReader(filename);
BufferedReader br = new BufferedReader(fr);
while(true)
curline = br.readLine();
if(curline == null)
break;
//determine the type of current interaction
boolean variable = curline.startsWith("input");
boolean constant = curline.startsWith("constant");
boolean equation = curline.startsWith("equation");
boolean output = curline.startsWith("result");
//on input variables
if(variable)
StringTokenizer st = new StringTokenizer(curline,delim);
int num = st.countTokens();
int count=0;
while(st.hasMoreTokens())
String temp = st.nextToken();
if(count==1)
byte b[]= new byte[100];
System.out.println(temp);
System.in.read(b);
String inputval = (new String(b)).trim();
variables.add(num_values,inputval);
num_values++;
count++;
// on constant values
if(constant)
StringTokenizer st = new StringTokenizer(curline,delim);
int num = st.countTokens();
int count = 0;
while(st.hasMoreTokens())
String temp = st.nextToken();
if(count==1)
byte b[]= new byte[100];
System.out.println(temp);
System.in.read(b);
String cons = (new String(b)).trim();
constants.add(num_constants,cons);
num_constants++;
count++;
// on equation
if(equation)
StringTokenizer st = new StringTokenizer(curline,delim);
int num = st.countTokens();
int count = 0;
while(st.hasMoreTokens())
String temp = st.nextToken();
if(count==2)
this.expression = temp;
count++;
// now we are ready to evaluate the expression
if(output)
org.nfunk.jep.JEP myparser= new org.nfunk.jep.JEP();
myparser.setAllowAssignment(true);
for(int i=1;i<variables.size()+1;i++)
String name = "arg"+Integer.toString(i);
myparser.addVariable(name,new Double(variables.get(i-1)
.toString()).doubleValue());
for(int i=1;i<constants.size()+1;i++)
String name = "arg" +Integer.
toString(i+variables.size());
myparser.addConstant(name,new Double(constants.get(i-1).toString()));
//output is obtained as follows
myparser.parseExpression(expression);
result = myparser.getValue();
System.out.println("Assay value: "+result);
catch(Exception e)
System.out.println(e.toString());
return true;
public static void main(String[] args)
FileProcessing fp = new FileProcessing();
fp.processFile("input.eqn",":");
}here i need to generate the strings like 'enter value1' and respective text boxes dynamically . i should use this java program as business logic and a jsp page for view.
following given is my text file input.eqn
input:enter value1:arg1
input:enter value2:arg2
input:enter value3:arg3
constant:enter constant1:arg4
constant:enter constant2:arg5
equation:enter equation:(arg1+arg2)*(arg3+arg4)*arg5
result:Why do you double post ? http://forum.java.sun.com/thread.jspa?threadID=646988&tstart=0
Why dint that answer satisfy you ? And why dint you say so in that thread rather than posting the same question again ?
ram. -
How can I run this java program? Please help.
I have jmf installed, sunone running , the file may be in the wrong directory.
It is in some directory nowhere near the java lang dir.
When I try to compile or build i cant. I'm off on a basic thing.
here is the code.
import javax.sound.midi.InvalidMidiDataException;
import javax.sound.midi.MidiDevice;
import javax.sound.midi.MidiSystem;
import javax.sound.midi.MidiUnavailableException;
import javax.sound.midi.Receiver;
import javax.sound.midi.MidiMessage;
import javax.sound.midi.ShortMessage;
import javax.sound.midi.SysexMessage;
public class MidiNote
/** Flag for debugging messages.
If true, some messages are dumped to the console
during operation.
private static boolean DEBUG = false;
public static void main(String[] args)
try {
// TODO: make settable via command line
int nChannel = 0;
int nKey = 0; // MIDI key number
int nVelocity = 0;
* Time between note on and note off event in
* milliseconds. Note that on most systems, the
* best resolution you can expect are 10 ms.
int nDuration = 0;
int nArgumentIndexOffset = 0;
String strDeviceName = null;
if (args.length == 4)
strDeviceName = args[0];
nArgumentIndexOffset = 1;
else if (args.length == 3)
nArgumentIndexOffset = 0;
else
printUsageAndExit();
nKey = Integer.parseInt(args[0 + nArgumentIndexOffset]);
nKey = Math.min(127, Math.max(0, nKey));
nVelocity = Integer.parseInt(args[1 + nArgumentIndexOffset]);
nVelocity = Math.min(127, Math.max(0, nVelocity));
nDuration = Integer.parseInt(args[2 + nArgumentIndexOffset]);
nDuration = Math.max(0, nDuration);
MidiDevice outputDevice = null;
Receiver receiver = null;
if (strDeviceName != null)
MidiDevice.Info info = getMidiDeviceInfo(strDeviceName, true);
if (info == null)
out("no device info found for name " + strDeviceName);
System.exit(1);
try
outputDevice = MidiSystem.getMidiDevice(info);
outputDevice.open();
catch (MidiUnavailableException e)
if (DEBUG) { out(e); }
if (outputDevice == null)
out("wasn't able to retrieve MidiDevice");
System.exit(1);
try
receiver = outputDevice.getReceiver();
catch (MidiUnavailableException e)
if (DEBUG) { out(e); }
else
/* We retrieve a Receiver for the default
MidiDevice.
try
receiver = MidiSystem.getReceiver();
catch (MidiUnavailableException e)
if (DEBUG) { out(e); }
if (receiver == null)
out("wasn't able to retrieve Receiver");
System.exit(1);
/* Here, we prepare the MIDI messages to send.
Obviously, one is for turning the key on and
one for turning it off.
MidiMessage onMessage = null;
MidiMessage offMessage = null;
try
onMessage = new ShortMessage();
offMessage = new ShortMessage();
((ShortMessage) onMessage).setMessage(ShortMessage.NOTE_ON, nChannel, nKey, nVelocity);
((ShortMessage) offMessage).setMessage(ShortMessage.NOTE_OFF, nChannel, nKey);
/* test for SysEx messages */
//byte[] data = { (byte) 0xF0, (byte) 0xF7, (byte) 0x99, 0x40, 0x7F, 0x40, 0x00 };
//onMessage = new SysexMessage();
//offMessage = new SysexMessage();
//onMessage.setMessage(data, data.length);
//offMessage = (SysexMessage) onMessage.clone();
catch (InvalidMidiDataException e)
if (DEBUG) { out(e); }
* Turn the note on
receiver.send(onMessage, -1);
* Wait for the specified amount of time
* (the duration of the note).
try
Thread.sleep(nDuration);
catch (InterruptedException e)
if (DEBUG) { out(e); }
* Turn the note off.
receiver.send(offMessage, -1);
* Clean up.
receiver.close();
if (outputDevice != null)
outputDevice.close();
} catch (Throwable t) {
out(t);
System.exit(0);
private static void printUsageAndExit()
out("MidiNote: usage:");
out(" java MidiNote [<device name>] <note number> <velocity> <duration>");
out(" <device name>\toutput to named device");
out(" -D\tenables debugging output");
System.exit(1);
private static void listDevicesAndExit(boolean forInput, boolean forOutput) {
if (forInput && !forOutput) {
out("Available MIDI IN Devices:");
else if (!forInput && forOutput) {
out("Available MIDI OUT Devices:");
} else {
out("Available MIDI Devices:");
MidiDevice.Info[] aInfos = MidiSystem.getMidiDeviceInfo();
for (int i = 0; i < aInfos.length; i++) {
try {
MidiDevice device = MidiSystem.getMidiDevice(aInfos);
boolean bAllowsInput = (device.getMaxTransmitters() != 0);
boolean bAllowsOutput = (device.getMaxReceivers() != 0);
if ((bAllowsInput && forInput) || (bAllowsOutput && forOutput)) {
out(""+i+" "
+(bAllowsInput?"IN ":" ")
+(bAllowsOutput?"OUT ":" ")
+aInfos[i].getName()+", "
+aInfos[i].getVendor()+", "
+aInfos[i].getVersion()+", "
+aInfos[i].getDescription());
catch (MidiUnavailableException e) {
// device is obviously not available...
if (aInfos.length == 0) {
out("[No devices available]");
System.exit(0);
e
* This method tries to return a MidiDevice.Info whose name
* matches the passed name. If no matching MidiDevice.Info is
* found, null is returned.
* If forOutput is true, then only output devices are searched,
* otherwise only input devices.
private static MidiDevice.Info getMidiDeviceInfo(String strDeviceName, boolean forOutput) {
MidiDevice.Info[] aInfos = MidiSystem.getMidiDeviceInfo();
for (int i = 0; i < aInfos.length; i++) {
if (aInfos[i].getName().equals(strDeviceName)) {
try {
MidiDevice device = MidiSystem.getMidiDevice(aInfos[i]);
boolean bAllowsInput = (device.getMaxTransmitters() != 0);
boolean bAllowsOutput = (device.getMaxReceivers() != 0);
if ((bAllowsOutput && forOutput) || (bAllowsInput && !forOutput)) {
return aInfos[i];
} catch (MidiUnavailableException mue) {}
return null;
private static void out(String strMessage)
System.out.println(strMessage);
private static void out(Throwable t)
t.printStackTrace();Please post your code using code tags.
When I try to compile or build i cant.What is your question? Exactly what error message do you get? -
I would like to update my eMac from 10.4.11 to to 10.6.x How can I get this os version for the update?
Highest an eMac can go is 10.5.8...
Leopard requirements/10.5.x...
* Mac computer with an Intel, PowerPC G5, or PowerPC G4 (867MHz or faster) processor
minimum system requirements
* 512MB of memory (I say 1.5GB for PPC at least, 2-3GB minimum for IntelMacs)
* DVD drive for installation
* 9GB of available disk space (I say 30GB at least)
Trouble is appl no longer sells it, you have to search eBay & such for the full retail version, not any grey Install Disc.
There are workarounds if the 867MHz is the only hangup...
http://sourceforge.net/projects/leopardassist/
List of Applications Not Compatible with Leopard...
http://guides.macrumors.com/List:Applications_Not_Compatible_with_Leopard
Snow Leopard/10.6.x Requirements...
General requirements
* Mac computer with an Intel processor
* 1GB of memory (I say 2GB at least)
* 5GB of available disk space (I say 30GB at least)
* DVD drive for installation
* Some features require a compatible Internet service provider; fees may apply.
* Some features require Apple’s MobileMe service; fees and terms apply. -
How can i run my java program with out java language
Hai to every one ..Iam new to java language ...am using windows xp operating system , i did not installed java language in my system .. how can i run a java program with out installing java language... Which files is requied to run java program..?
any one can help me??Hai to every one ..Iam new to java language ...am
using windows xp operating system , i did not
installed java language in my system .. how can i run
a java program with out installing java language...
you ... can ... not ... do ... this
Which files is requied to run java program..?
any one can help me??a JVM. Download it from sun's website.
[url http://java.sun.com/javase/downloads/index.jsp]Download JavaSE here -
I have 13 dollars left on an apple store gift card, how can I convert this into money for my iTunes account?
You can't.
-
My ipod nano was synced by itunes and removed all of my music and game files, and replaced my music with my kids music that they have put into the current itunes library. My music is nowhere to be found on my computer, so now I am in the long, forever process of adding my music back one cd at a time, but there is no history of tetris that I paid for from the itunes store. How can I get this game back for my ipod?
Contact iTunes support and explain your situation to them. They may let you redownload it at no cost.
http://www.apple.com/support/itunes/contact.html
If they don't, I'm afraid you'll have to purchase it again. Sorry.
B-rock -
After I downloaded the new version of iTunes 11.0.1 and i try to open it it says: ''There is no application set to open the document ''iTunes 11.0.1.dmg.part''. How can i install this without paying for an app to do it? What apps can i download to do this type of work.
.dmg.part is not a complete file.. It usually indicates that the entire file has not been downloaded yet. Are you sure you downloaded the entire file? (i recommend updating itunes through > Software Update
Alternatively, you can download it from here: http://support.apple.com/kb/DL1614 -
Cannot launch LR. Photoshop crashes after few seconds. How can i fix this? Thx for help
Hi members & mvp's
I face same problem, after creating Adobe ID and after installing Creative Cloud app, the installed Ps and Lr can't be launched... Lr at all, no action, but Ps works for a few seconds. I could achieve "system info" from help menu as follows:
Adobe Photoshop Version: 2014.0.0 20140508.r.58 2014/05/08:23:59:59 x64
Operating System: Windows 7 64-bit
Version: 6.1 Service Pack 1
System architecture: Intel CPU Family:6, Model:10, Stepping:9 with MMX, SSE Integer, SSE FP, SSE2, SSE3, SSE4.1, SSE4.2, HyperThreading
Physical processor count: 2
Logical processor count: 4
Processor speed: 1895 MHz
Built-in memory: 3990 MB
Free memory: 1477 MB
Memory available to Photoshop: 3303 MB
Memory used by Photoshop: 70 %
I guess my PC is powered enough, but I'm afraid other trial versions and registry rubbish are locking CC server communication. Do you know some tool to clean up previous installation of Adobe products?
Thanks in advance!
Jose -
I upgraded to OS8 for my Iphone 5 and now I have no access to e-mail and several apps. How can I address this problem? For those who have an iphone 5 I recommend not upgrading to the new OS until these bugs are resolved.
I foolishly downloaded OS8 on my iPhone 4S. It not only greyed out my wifi button making it impossiblr to use wifi, but bluetooth connection doesn't work either. I reset the phone to factory settings but that did nothing apart from loose all my photos and contacts. OS 8 was still on after too. Apple say it is a problem but the download only brought the fact the hardware was faulty to the fore, but not being under warranty , the repair would cost £166 that I would have to pay. Totally unacceptable. If the problem was known and they knew it would cause problems on older models, why have it bob up on iTUNES for download.
Don;t download it guys, APPLE aren't admitting culpability and it will cost you a fortune to put right!! -
Since updating my iPhone 4 to iOS5, my music stats (play count, last played, etc.) no long sync to iTunes. How can I fix this? Thanks for the help.
If you have any podcasts in your iTunes library you should see a Podcasts sync setting tab to the right when you connect your phone and click on its name on the left sidebar (see image below). On this tab check to sync podcasts and sync your phone.
-
How can i apply this glowing effect in logo with illustrator?
How can i apply this glowing effect in logo | ThemeForest Community Forums
I would make several copies of the original artwork. On each copy, section the individual areas to be gradients. It looks like you have at least four gradients, both linear and radial. It's just a matter of building each section and then reassembling each. Not too complex, yet nice piece of artwork.
-
How to Generate a Java file for a JSP Page
Hi ,
I am using weblogic11 .
I am working on a JSP page which nearly consists of 4000 lines of code.
I need to debug the file , but weblogic server is not generating the java file for the JSP pages .
Please let me know how can i genertae Java file for the jsp pages ??JSPs are compiled into servlets automatically and those classes are stored in WEB-INF/classes folder. Servlet engine handles servlets.
-
How can i hand the RowSet to the next jsp page
In a jsp page, I get a RowSet as the following:
<input type="hidden" name="result" value="<%=ds.getRowSet()%>">
I want to handle with this RowSet in the next jsp page, so
I do in the next jsp page as the following:
<% RowSet rowset = (RowSet)request.getAttribute("result"); %>
But I was told null error. How can i hand the RowSet to the next jsp page.Help. Thanks a lot!Hello Charles,
I did the registration in the same way as in the JDeveloper 3.2.3 (see follows)
// make sure the application is registered
oracle.jbo.html.jsp.JSPApplicationRegistry.registerApplicationFromPropertyFile(session , "ReefBC_BCPackage_BCPackageModule");
The argument ReefBC_BCPackage_BCPackageModule is a property file (ReefBC_BCPackage_BCPackageModule.properties). After some tries, I can still use it in JDeveloper 9i R2. The reason to keep it is that there would be a lot of migration work of javabean calling if I change it to <job:DataWebBean..>. But I am wondering, do I initialize two application modules when I use registerApplicationFromPropertyFile() and <jbo:ApplicationModule..> in the same page.
The problem in doStartTag() is found after I post "http://forums.oracle.com/forums/thread.jsp?forum=83&thread=155210&tstart=75&trange=15", by tracing into the <jbo:ApplicationModule..> after calling the OrdHttpUploadFormData. HtmlServices.getRequestParameters sends back an exception, that breaks the running of the program. It was temperorily solved by extending the ApplicationModuleTag. If <jbo:..> could use the application module initialized by registerApplicationFromPropertyFile(), I guess it may be a better workaround.
Long postings are being truncated to ~1 kB at this time. -
How can you get a java program working on a cell phone?
I was thinking of making some stuff for cell phones so i was wondering how you get a normal java program to work on cells.
its all j2me - midlet package....Huh? The jsr-118 MID profile alone has 11 packages, one of which is javax.microedition.midlet. Notj2me - midlet.
works best on nokia phones.Sez who? You seem to be confusing Java ME with Symbian C.
you can use net beans midlet packge add-on.Only it's called the NetBeans Mobiliity Pack.
Its easy to use and has lots of tutorials.Ditto for the Wireless toolkit for CLDC.
just search on google.Yes, but with which keywords?
@OP:
NetBeans mobility pack comes with a short tutorial and several samples, you also need to download the latest WTK as the ver. 2.2 which comes bundled with NetBeans is just too buggy to work with. Then there are the manufacturer-specific SDKs from Nokia, Motorola, Sony Ericsson and (maybe) others.
If and when you get started in Java ME aka j2me, it will be appropriate to post any questions you might have on the mobility forums, not here.
Google "j2me tutorial" for many good hits.
luck, db
Maybe you are looking for
-
I'm using Jabber for Windows with a Webex backend for IM&P with CUCM and Unity Connection on-site. It looks like I can use SSO for logging into Webex with Jabber but I wanted to confirm if it will also work for logging into CUCM with the phone servic
-
Planning db from SQL server to Oracle
Hi Friends We are planning to upgrade our Hyperion Environment from 9.3.3 to 11.1.2.2. and we are going from SQL server to Oracle as our RDBMS. If we are changing DBMS, do we have to rebuild total application or is there any easy method to migrate fr
-
PLAYLIST order and SEARCH option
how do i get the playlist to play songs in a specific order i have renamed all filenames and idtags and still they come in chaos and another thing: SEARCH option newer ipods come with the search option (as i read at apple site). i updated my 30G 5th
-
Patch set for oracle-8.1.5
Hi, Does anyone know where can i get patches for bug:883333 ==> import error where schema contains synonym. FYI, I'm currently using Oracle8.1.5 on AIX4.3.3. I'm already report this problem to Metalink but they still not upload the patches. TQ
-
Registry settings for burning missing
I am also one of the many people who now, after installing v. 5.0.1, get the message that itunes cannot find the registry settings to allow me to burn cds. I didn't have this problem with 5.0, so i am getting upset. I have tried to repair itunes, but