Current Options For Applet To Servlet Communication
Feb 12, 2014
My primary question is about which method is the best for having an applet of mine communication with a backend database of mine. In other words, I don't want to try learning a technology that is out of date or not a good fit for my goal. I purchased the O'Reilly title "Java Servlet Programming", but it seems to be very old and out of date (referencing Netscape 4, etc.) and I see a Java RMI O'Reilly title on Amazon, but it was written in 2001.
My basic goal is to allow my applet to have access to a back-end database for reading and writing. I understand that direct Applet to DB (via JDBC) access is a bad idea so my thought is to create a servlet (much like web service for lack of a better term) or an actual web service (RESTful would be my first guess) to broker the requests. I already have a very basic servlet running that has access to my database server so now I want to focus on the best method for making calls from the applet to the servlet but having said that I don't want to go down this road too far if a servlet is not the right tool for the job.
My reading has been leading me to RMI, but as I said, I don't want to focus on that if there is a better option. In a non-Java environment, I'd use a web service (REST, SOAP, etc.) and perhaps that's what I should do here as well and not even bother with a servlet per se and just go with a web service.I know there can be some subjectivity with regard to these choices and I don't need to know what the "best" one is.I don't want to use RMI if it's dead or has been surpassed by something else, for example.
Should I use a servlet? Should I use a web service? My needs are rather modest; query the database, send updates to the database, etc. Nothing too crazy.
View Replies
ADVERTISEMENT
Feb 22, 2013
We have two servlets application running on same server with Java EE 6 with below mention application URL.
Servlet1 Application URL: http://<severname>/*servlet1*
Servlet2 Application URL: http://<severname>/*servlet2*
My question is how to call Servlet2 from Servlet1 with Post method without using server name. May be something like this:
servlet.invoke(servlet2).
View Replies
View Related
Mar 6, 2014
How can i assign current null value to current date, I only what to assign this if the current value coming from database is null otherwise i must use value from database
public static String getDate(Calendar cal){
return "" + cal.get(Calendar.DATE) +"/" +
(cal.get(Calendar.MONTH)+1) + "/" + cal.get(Calendar.YEAR);
}
try {
[Code] .....
View Replies
View Related
Mar 17, 2015
I want to be able to use the current date to solve a math problem, specifically as follows:If today is March 17, the math problem of the day should be:
(Month times Day of Month) + 99 = Answer of the Day
(3 x 17) + 99 = 150
How can I create a java script to find the current month and the current day of month, multiple those two together, then add 99 and display the answer as a result.
View Replies
View Related
Dec 10, 2014
Where can I find a complete list of available JVM options for WLS? For example -Dweblogic.security.SSL.protocolVersion is not listed anywhere
View Replies
View Related
Mar 13, 2014
I was wondering, for both a web based application and a normal Java program, should I just open up an I/O every time I need certain data, or am I better off just loading all the information into my program at start up?
View Replies
View Related
Oct 11, 2014
In the code that I am currently trying to do, I want to make it so that the program loops until the randomly generated number is 1, to a maximum of 4 loops.I have figured out how to make it stop at a randomly generated 1, but I can't quite figure out how to make it stop at four loops if it doesn't reach the 1 before the maximum number of loops.
View Replies
View Related
Feb 17, 2014
I installed Netbeans 7.0.1 but I couldn't find border option's more fonts and color palette as being 7.4.
I would like to download.
I want to change Panel's border color and font but when I click there is few fonts and color options.
View Replies
View Related
Jul 9, 2015
We currently have an application which uses JDBC to connect to the backend database (DB version - 11.2.0.3 ). The application uses a properties file in which the password for the db schema is hardcoded in plain text format. Due to security restrictions we have been asked to make sure the password is encrypted in the file and no direct access is made to the schema using the plain text password. Best options we can use to make this password encrypted both at Oracle DB side and Java side.
View Replies
View Related
Jan 23, 2013
I am a beginner want to compile servlet with following path
javac -classpath Program FilesApache Software FoundationTomcat 5.5commonlibservlet-api.jar;classes:.-d classes srccomexamplewebBeerSelect.java
Problem arises as follows:
javac: invalid flag: FilesApache
Usage: javac <options> <source files>
use -help for a list of possible options
View Replies
View Related
Dec 6, 2014
I have all of my code written, but it is not producing any output and i'm not sure why.
import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.File;
[code]...
View Replies
View Related
May 23, 2014
I'm writing a small program in Java to simulate a shopping cart. A shopping cart has an array og objects Item. As a console application, my program runs.But, in the GUI version, I have some issues. In class MainMenu I create a ShoppingCart object, named "cart"(line 103)In class AddItemMenu I create an Item object, and I want to add it in my ShoppingCart object "cart".BUT, AddItemMenu cannot "see" variable "cart".
//MainMenu.java
package shoppingcartgui;
public class MainMenu extends javax.swing.JFrame {
public MainMenu() {
initComponents();
[code]....
View Replies
View Related
Nov 1, 2014
I'm new to java and haven't develop any application before that... I need to develop an application through which i can send data from 1 computer to another computer. These communication in between the computers are those are under one router connection. Means they can connect even without internet access
Main concept is as follow
1. Java application on computer A [server side application]
2. Java application on Computer B [Client side application]
3. Java application on computer C [Client side application]
Now computer B and C communicate with computer A. but they don't know about presence of each other
View Replies
View Related
Jul 22, 2014
I'm deployed application A and application B in TOMCAT server applications, the U1 user enters into the application A, he authenticates and generates a call to a page of the app B. As I was able to access the session of user U1 en A from B, it could have a single session.
View Replies
View Related
Apr 19, 2014
I have a jFrame and a Java Class. Now i have a path of image in my jFrame which I want to display in java class(Crop2). I created an object in jFrame
Crop2 d=new Crop2();
and then I'm trying to send the data to the class file but it is not working.
View Replies
View Related
Sep 20, 2012
I have two separate java Program that run on the same
computer : Program -1 & Program-2 .
Explain Program-1 :
Name of Program -1 is “InputFrame” that is a simple frame that contain a JTextField and a Button and a JTextArea .
Explain Program 2 : Name of Program-2 is “OutputFrame” that is a simple frame that contain a simple JTextArea that this JTextArea is a Instance object from a class with name of “DisplayFrame” .
This instance object from class of “DisplayFrame” added to frame of “OutputFrame”.Now I want run both Program 1 & 2 simultaneously in the same computer and when I enter a text in JTextField in Program-1 and after click on the Button “OK” that Text Entered in this JTextField In addition to JTextArea in Program-1 display In JTextArea in Program-2 .
I do not want use a share file between two Program-1 and -2 Or DataBase .I want if Program-1 run but Program-2 is not running and i enter a text in JTextFeild in Program-1 , after running Program-2 that Entered Text Displaye in JTextArea in Frame of Program-2 .(Offline Message) .Both Source code of Program-1 and Program-2 is Attached .
View Replies
View Related
Aug 4, 2014
The following programs exist:
1. I have a java application which accepts bio potential data every second or two and stores it in the database. This is a socket server which accepts this data from multiple clients and spawns a new thread for processing it to store in the db.
2. I have a jsp page on tomcat server which reads historic client data from database (stored by application 1) and displays it on the page.
The socket server program in 1.) above is not running inside of tomcat server.The new requirement now is : Display all of the human data coming in live on the jsp page.Now the problem: I will now need to pass the live data from socket server (which is stand alone) to the jsp which is running on a tomcat server.
Possible solutions:
APPROACH 1: Run the socket server in the tomcat instead of stand alone and store the frequently incoming data in a java object so the jsp can access this object every second and display it on a graph.
PROBLEM : The stand alone java application does not need to be included in a tomcat server except for the fact that the jsp needs access to the live data. Also, I have read that this is not the best way.
APPROACH 2: Expose the stand alone java application as a web service and communicate with the jsp using REST architecture.
PROBLEM : The complication of using this method is that it will not have the flexibility offered by websockets or server sent events (SSE) of auto updating the latest data. The jsp will have to keep polling for new data every one second which is also not a very good option.
View Replies
View Related
May 29, 2014
I want to make project about java communication with hardware (wiz110sr) via LAN (Rj45). And for example, my hardware have ip address 198.168.0.1 ; port: 1202, connected with my PC(via lan/Rj45). I want show the output (such as numbers and letters) from my hardware in console netbeans.
When I running my code, appear :
" Exception in thread "Thread-0" java.lang.RuntimeException: Uncompilable source code
at mypkg.startListenForTCP$1.run(startListenForTCP.ja va:48)
at java.lang.Thread.run(Thread.java:745)
BUILD SUCCESSFUL (total time: 1 second) "
Here's the code :
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.InetAddress;
import java.net.Socket;
import java.net.UnknownHostException;
import sun.rmi.runtime.Log;
[Code] .....
View Replies
View Related
Feb 6, 2015
Firstly, my code is just a demo of my multiplayer game (2 or more players can play simultaneously) to demonstrate my problem without any extra things. I have successfully implemented peer-to-peer (P2P) communication in my game. Later, I decided to add support for client-server communication (ie a central server which is also a player) in my game. It should be much easier than P2P. Now here is the problem:
Suppose, I have 1 server and some clients (may be 1 or more clients). They all should give the following output:
Starting...
A
B
C
E
F
...
...
Done!
They all give the above output without using multi-thread. But using multi-threading, it gives the above output only when there're 1 server and 1 client. I'm using 2 threads (1 for sending, 1 for receiving) for each Socket. That means, each client has only 2 threads for communication but the server has (2 * totalClients) threads.
I've attached my full test project. So, here I'm only showing my 2 thread classes.
ReceiveThread class:
class ReceiveThread extends Thread {
private ObjectInputStream receiveStream;
private BlockingQueue<Character> queue = new ArrayBlockingQueue<Character>(Common.totalClients);
[Code] ....
Since I've attached my full test project, I'm not showing the other 3 classes. They are ServerMain, ClientMain and Common. If I've 2 clients to be connected, then I get the following output:
Server: (Runs first)
Starting...
A
Client 1 (clientID is 1): (Runs after the server)
Starting...
A
B
B
Client 2 (clientID is 2): (Runs after Client 1)
Starting...
A
They are stuck at there, even no exception. Actually, the server and the clients are stuck at the line try { ch = queue.take(); } if more than 1 client are connected. It seems that all are trying to receive data. But without using the dedicated threads, they all work as expected even for more than 1 client. Why is this behaviour? How to solve it? Note that I have used the same SendThread and ReceiveThread classes by which I have succcessfully implemented P2P communication.
About my attached test project file:
It has 5 small .java files for the classes as stated above. It is currently faulty when using additional threads. You have to change clientID variable for each client (they are described inside). But it works as expected without additional threads. To test it without the additional threads:
Comment " TODO" linesUncomment the single lines just after " TODO" linesComment the additional thread construction lines (4 lines)
Currently, for a workaround, I'm not using the dedicated threads for sending and receiving data only for client-server communication in my multi-player game. But I'm still using these threads for P2P communication. I don't know why it is and how to solve it.This is the attached test project file as described above.
Attached File(s) : Test Project.zip (4.11K)
View Replies
View Related
Nov 13, 2014
I need to write a program that prints the current time every second. Here is what I have and I am not entirely sure why I'm not.
Java Code:
import java.util.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.Timer;
public class CurrentTime
[Code] .....
View Replies
View Related
Jun 2, 2014
I am trying to get the current utc date/time, but it keeps printing out in local time:
Java Code: LocalDateTime dt = LocalDateTime.now();
ZonedDateTime zdt = dt.atZone(ZoneOffset.UTC);
System.out.println("time: " + zdt);
// output:
time: 2014-06-02T13:37:55.705Z mh_sh_highlight_all('java');
13:37 is local time. Utc time is 17:37.
View Replies
View Related
Mar 18, 2014
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Scanner;
public class Swipe_In {
public String DTStart; //Swipe in Date Time
[code]....
I have got 2 questions on the above class...
1) I get an error "Cannot make a static reference to the non-static field DTStart" wherever i use DTStart in the main method....What's causing this error? and How do i fix it for good?
2) public String DTStart; Once i get the current date & time assigned to the above DTStart String in the main method i cannot use the updated value of DTStart in any other class. In another class i wanna create an instance(object) of this Swipe_In class with DTStart assigned to the current time(as in its main method)..I tried but the object's DTStart gets assigned to null.(( How do i achieve this?
View Replies
View Related
Jun 24, 2014
First of all, i am using ubuntu and jdk8. My problem: displaying the current path of a file in my system Approach: I have a file called dummy.txt in a given directory which have enough permissions and i did the following:
File file=new File("dummy.txt");
System.out.println(file.getAbsolutePath().substring(0,file.getAbsolutePath().lastIndexOf("/")));
I expected to see displayed the current path of the file without the name of the file but it is showing a different path. I just want to display the current path of the file without the name.
View Replies
View Related
Sep 14, 2014
Following is the code on the click of a button, id like to know how do i close the current jframe on which the jButton4 is currently placed. I know how to send it to the next Jframe i.e JobCard. But need to close the current one. I tried using this.setVisible(true); But it does not work.
private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
this.setVisible(false);
JobCard jobCard = new JobCard();
jobCard.setVisible(true);
}
View Replies
View Related
Nov 10, 2014
Basically we have to create a calculator that it will have to keep track of the current value, and do the functions that the calculator uses.
But I have it working for the most part, but the current value does not keep...
The double " currentValue " Must stay private.
import java.util.*;
public class MemoryCaluclator {
private double currentValue;
public static void main(String[] args) {
Scanner stdIn = new Scanner(System.in);
int answer = 0;
[Code] ......
View Replies
View Related
Jun 29, 2014
Can we set the class path for one level down the current directory? My structure is like
binlibresourceshexicon.cmdinside the folder dist.
In this case I could run the .cmd file which has java -cp .;lib;resources client.Test .
c: rycpdist>java hexicon.cmdBut if i put the .cmd file inside bin as like this and run as
c: rycpdistin>java hexicon.cmdI am getting this error Error: Could not find or load main class
Is there any possibility to set the class path in this case
View Replies
View Related