I/O / Streams :: How To Send Messages Efficiently From Backend To Frontend

Apr 8, 2014

I'm working on a project that has two separate components. The first is a back end, that will do most of the heavy lifting, the other part is a front end GUI. The GUI will include the back end into it's project as an imported JAR file.

I need to be able to keep these two decoupled, as I might be writing different front ends using the same back end. The challenge in front of me (well one of many) is how to pass messages from the back end to the GUI so I can report things that are happening.

For example, if i call method FOO, FOO might do several different things; connect to a database, divide by zero, solve world hunger. I want to be able to either tie a JTextArea , or another component (or multiple components) to this stack of information, or at the very least, have something listening for this information, and when I see that my back end reports something, my front end is quickly aware of this information, and then I can process it and inform the user of the front end.

It would also be useful to be able to send a message from front end to back end , so perhaps the back end might learn that the front end user is unhappy and would like to stop running the current query.

View Replies


ADVERTISEMENT

Open / Send Multiple Messages Over TCP And Close Connection On Events

Oct 7, 2014

I have a simple method in Java through which I send commands to a machine over TCP. The problem is:

Machine can't accept more than two connections in 20 seconds.

I need to send 15-20 commands to the machine in 3 minutes.

This is my current method which is not working as it should, 2 commands get transmited but third command hangs because of the machine.

void sendCommand(String command) throws IOException {
String ipaddress = "192.168.0.2";
Socket commandSocket = null;
BufferedWriter out = null;
BufferedReader in = null;
BufferedWriter outToDetailFile = null;

[Code] .....

Basically what i need is:

1st: I need to open the connection by calling method

public void openConnection(String ipaddress, String port){
//Code to start the connection
}

2nd: I need to be able to send commands to the connection I have already opened (i will send multiple messages in time period of 5-10 minutes):

public void sendCommand(String message){
}

3rd: Close that connection

public void closeConnection(){
}

View Replies View Related

I/O / Streams :: Best Way To Send ArrayList From Server To Client?

Jun 14, 2014

What is the best way to send an arrayList from the server to the client? ObjectInputStream and ObjectOutputStream?

View Replies View Related

Fill Different Size Boxes With Bags Most Efficiently

Jan 23, 2015

I have to write an example program to fill boxes most efficiently with bags. All bags are the same size. The boxes come in Large, Medium and Small. Large boxes hold 20 bags. Medium boxes hold 10 bags. Small boxes hold 5 bags. I am getting input from JOptionPane input dialog box and then parsing that input to an integer.

I have to fill the large and medium boxes completely. I am not sure how to do this without an if statement. I can use one, but we have not covered it in class, so I am skeptical about using one to solve the problem. If I just divide the input number with integer division, I'm not going to get the remainder, right? So I'm thinking that I can mod my input number by 20 (the number of bags the user inputs) and then mod that number by 10 and then mod that number by 5, would that work?

View Replies View Related

JSF :: Building Web Frontend For Command-Line-Based Software

Jun 17, 2014

The goal of this software is to provide a web interface which must be able to manage the Quagga routing daemon. For those who don't know Quagga, the only interface it provides the user is its built-in cli. My project must convert web events to commands and vice-versa. how I'm going to maintain quagga's configuration state synchronized with JSF's managed beans. The example below shows the commands one must run on quagga's cli in order to add a BGP neighbor:

neighbor 10.0.0.1 remote-as 65535
neighbor 10.0.0.1 description "Just a Test"
neighbor 10.0.0.1 next-hop-self
neighbor 10.0.0.1 soft-reconfiguration inbound
write memory

In order to represent this piece of information in my project, I was thinking about mapping this to a class:

public class BGPNeighbor {
private String ip_address;
private Integer asn;
private Boolean next_hop_self;
private Boolean inbound_soft_reconfiguration;
}

With this I would parse the information from Quagga's configuration and map this to classes in my software. I think it's a lot easier to do with database-based software, the problem with this project is that it's not completely database oriented. The information must be fetched from the network, parsed, converted to classes and then they would be available to JSF as managed beans. Any alteration to this classes must be converted to quagga cli commands which must be executed through the network again (telnet).

View Replies View Related

Servlets :: Generate Graph From Backend Database?

Jun 7, 2014

1) I will have to create two columns in MYSQL database and insert data in that, each column contain 8-9 k data.

2) Then i need to plot this data in chosen GUI in three separate plots on one screen as shown in attached image.

3) Time interval for X-axis for plotting individual graph is 0.001.

4) Then i need to plot these two waveform data against each other as XY graph as shown in graph.

How to do this or what language and technique i need to choose.

View Replies View Related

Servlets :: Fetch Data From Backend (DB2) And Export To Excel - Slow File Download

Jan 31, 2014

Recently we got an issue about file download. We are using below code to fetch the data from backend(DB2) and export to excel.

Before Jan 15 it use to take 2 minutes to download the file (2 MB size). But now its taking half an hour to download.

response.setContentType("application/vnd.ms-excel");
response.setHeader("content-disposition","attachment; filename=Attendance_Report.xls");

We have restarted server, system but still problem exists. We found that there is no code level or data base level or network level issues.

Now we have to see server level issue. What are the factors which effects the file downloading at server level.
We are using websphere 6.1 ,java1.4

View Replies View Related

JDBC :: Options Required For DB Schema Password Encryption - Connecting To Backend Database

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

If Statements - Printing Messages

Jun 11, 2014

I have a small problem with my code that I can't figure out how to make it work the way it is supposed to. The code is supposed to be a game where a user has to guess numbers between 1-1000. The program counts how many times the user tried to guess the number and it displays a certain message if the guess number is less than 10, more than 10 or 10. I was able to write the code using loops. However, the messages will not always get printed on to the screen. The code seems to work fine except for the last part where the messages, "Either you know the secret or you got lucky", "You should be able to do better", "Aha! you know the secret!" are not always displayed like they are supposed to.

import java.util.Scanner;
public class Guess1 {
public static void main(String[] args) {
int secretNumber;
secretNumber = (int) (Math.random() * 999 + 1);
Scanner input = new Scanner(System.in);
int guess;
int replay;
int test;
test=1;
replay=1;
int count=0;
 
[code]....

View Replies View Related

Logger Logs Old Messages

Mar 4, 2014

I have the following code that comes directly from the book Core Java vol 1. The last two statements are mine but when I change the last statement's String the message being logged doesn't change. For that manner when I change the level of the last statement the file doesn't update to the correct log level. What am I doing wrong?

Java Code:

public class LogTester
{
public static void main(String[] args)
{
if (System.getProperty("java.util.logging.config.class") == null
&& System.getProperty("java.util.config.file") == null)

[code]....

Forgot to say the file also only logs the old message and level from a previous recompilation

View Replies View Related

Processing Queue Containing Dissimilar Messages

May 25, 2014

I am new to Java/OOP in general, and am trying to implement a multi-threaded system that contains a master thread, and a set of worker threads that are heterogeneous in the work they do. Once they complete the work, the workers indicate to the master by posting the result on to its queue. Here is the problem. The results of each type of work is different, and the master has to process each differently. In C (which I'm familiar with), this can be achieved by having a message type that is a union of all the expected messages, and by using a switch statement.

I thought of doing something similar in Java, by using instance of on each incoming message (each individual message class having been subclassed from a super message class) , and doing switch on that, but it doesn't seem to be the OO way to do things. The only other way I could think of was to implement an abstract method to get the type of each message, and then use the type in a switch statement, or if-then-else. Is there some other Java idiom to do this kind of processing? Also, if this is an acceptable method, why is it superior to using the reflection to find out the message type (instead of using the abstract getType())?

The message types look similar to the code below:

abstract class Message {
abstract String getType();
} class Result1 extends Message {
ResultType1 content;
String getType() {

[Code] ....

View Replies View Related

EJB / EE :: Reject Duplicate Messages In ActiveMq

Jun 13, 2014

I am using ActiveMq alongwith Spring in my project. I want my queue to be configured to reject the duplicate messages.I tried my level best to do so. I tried googling for the same. but could not get anything.

View Replies View Related

Storm Chaser With Error Messages

Mar 1, 2015

I am having issues with a few lines of code and a java.util.UnkownFormaException. Here are the issues:

Exception in thread "main" java.util.UnknownFormatConversionException: Conversion = '1'
at java.util.Formatter.checkText(Unknown Source)
at java.util.Formatter.parse(Unknown Source)
at java.util.Formatter.format(Unknown Source)
at java.util.Formatter.format(Unknown Source)
at java.lang.String.format(Unknown Source)
at Storm.toString(Storm.java:99)
at StormChaser.DisplayStorms(StormChaser.java:149)
at StormChaser.main(StormChaser.java:55)

I have tried a lot of different things but can't seem to figure it out.

import java.io.*;
import java.util.Scanner;
public class StormChaser {
public static void main(String[] args)

[code]....

View Replies View Related

Enterprise JavaBeans :: How To Refresh JPA Data When Table Data Is Updated From Backend

Nov 27, 2012

Is there a way to inform the Entity Manager or force the JPA provider to reload data from the database? The scenario could be data being updated by a store procedure or direct SQLPlus maintenance, without restarting the Application Server, the JPA need to load the newly updated data from the database.

I think the current JPA API is not enough. The void refresh(java.lang.Object entity) from EntityManager need to pass in the Entity object, I will like to know how to refresh the entire JPA Entity data after the physical table data being update from backend.

View Replies View Related

EJB / EE :: MQ Messages Getting Re-delivered Infinitely With Exception In System Out

Apr 7, 2014

MQ Issue on the Websphere 7.0.0.25 server ..Same Message is getting redelivered again and again and below exception is coming in System out log. And secondly the messages are not getting processed completely.

[4/7/14 12:14:58:616 GMT+05:30] 0000001e LocalTranCoor E WLTC0017E: Resources rolled back due to setRollbackOnly() being called.
[4/7/14 12:16:14:738 GMT+05:30] 00000062 LocalExceptio E CNTR0020E: EJB threw an unexpected (non-declared) exception during invocation of method "onMessage" on bean "BeanId(myroj#myEJB.jar#MQMessageReceiverMDB, null)". Exception data: java.lang.reflect.InvocationTargetException
at sun.reflect.GeneratedMethodAccessor77.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
at java.lang.reflect.Method.invoke(Method.java:599)
at com.ibm.ejs.jms.listener.ServerSessionDispatcher.dispatch(ServerSessionDispatcher.java:47)
at com.ibm.ejs.container.MDBWrapper.onMessage(MDBWrapper.java:98)

[code]...

View Replies View Related

Maintain Separate Files For Different Types Of Messages

Sep 19, 2014

I am attempting to maintain separate files for different types of "messages" (user messages, field labels/buttons, data values). In this attempt I am trying to get the description of different data values. For example, a UserStatus "A" might be displayed as Active or Activo.

<bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
<property name="defaultEncoding" value="UTF-8"/>
<property name="basenames">
<list>
<value>WEB-INF/locale/messages/messages</value>
<value>WEB-INF/locale/fields/fields</value>
<value>WEB-INF/locale/values/values</value>
</list>
</property>
</bean>

Here are the relevant entries in the values_en_us.properties file:

user.status.A = Active
user.status.I = Inactive
user.status.P = Pending

I would like to build an Enum for each type of value that I can get the localized value from. In the code below, I have hardcoded the values being passed to the get message to reduce the number of variables when trying to debug this.

import java.util.EnumMap;
import java.util.HashMap;
import java.util.Locale;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public enum UserStatusEnum {

[Code] ....

When this code runs, I get the following message:

org.springframework.context.NoSuchMessageException: No message found under code 'user.status.A' for locale 'en_us'.

On this line of code:

description = appCtx.getMessage("user.status.A", null, new Locale("en_us"));

The application is already showing my custom application error messages I have in the messages localized files, but in that case the ApplicationContext is already available. Because I can get to the contents of the messages_en_us.property files, I'm assuming me config is correct. However, the classes that get the messages content are instantiated by Spring.

The Enums are not created by Spring, so my assumption is that I am doing something wrong in how I am getting a handle on the ApplicationContext or how I am using it.

After looking at the appCtx values in debug mode, I can see that the messageSource > basenames does at least contain my configuration data.

[WEB-INF/locale/messages/messages, WEB-INF/locale/fields/fields, WEB-INF/locale/values/values]

Although I don't see the whole filenames with the file extension anywhere or the property file entries.

View Replies View Related

Java EE SDK :: How To Push Messages From Server Side

Jan 18, 2012

I have some data in the database and values can be added on demand. so when ever the value added to the database i need to promt that message to all users which are accessing my website, so how can i acheive this....

View Replies View Related

JSF :: Primefaces - Two Messages Getting Displayed Instead Of One For Ajax Blur Event

Jan 28, 2014

I have one row editable datatable.I have implemented email validation to one of the column where error message must display on blur of email field.This is working fine.I have a dialog with form to be displayed in the same page. Validation is implemented to this form also with on blur event. The dialog validation message gets displayed on blur but along with that the main form also displays the same validation message. This should not happen.

JSF page

<h:form id="lpcForm">
<div id="content">
<p:commandLink id="cmdLinkDelete" value="Delete"
style="font-size:15px;padding-left:15px;" ajax="true"
action="#{lpcBean.deleteRecords}" update=":lpcForm:lpcDataTable" />
  
[Code] ....

The message with id lpcErrMsg is the one that i am displaying on blur in the main page when email format is wrong.And this message gets displayed with dialog field validation also although i have never referred to this id to be rendered in the dialog.

The message with id lpcDlgMsg is the message that i am displaying inside the dialog with widgetvar dlg on blur.As of now i have implemented blur event validation for the first required field in the dialog.

View Replies View Related

Display Some Messages On Output File In Display Head Function

Mar 18, 2014

Write a class named FileDisplay with the following methods:

1.) constructor: the class's constructor should take the name of a fil as an arugment.
2.) displayHead: This method should display only the first five lines of the file's contents

Here is the following code I have made so far

import java.io.*;
public class FileDisplay
{
private String filename;
 public FileDisplay(String Filename) throws IOException

[Code] ....

First, in my constructor I have taken in an argument and used that argument to open up an output file. Meanwhile, I'm trying to work n the displayhead method to print out information and to read data to. I haven't opened up my input file yet, but I'm not understand how can I read a print data to an output file. in

public void displayHead()
{FileWriter file=new FileWriter(Filename)}

do I make create another instance of the filewriter class to output data?

In simple words, suppose to I want to display some messages on my output file in the displayhead function. Since I already have opened up the file in the constructor, how do I combine that in this method...

View Replies View Related

How To Send SMS Using Java Program

Dec 22, 2014

How to send sms to mobile using java program. I have tried lot of examples, I didn't get perfect example ?

View Replies View Related

How To Send SMS Using Java Web Application

Dec 3, 2014

I am working on a Java Web Server application.In which server needs to send message to a Mobile no?

What are the way to send message to a mobile no by Java application.

by reading online threads i found like

[URL]

which one I should use and any other approach other than these to send a message using java application?

View Replies View Related

How To Send SMS Through Java Application

Jan 16, 2014

how can I send a sms through java application?

View Replies View Related

Send Email Through Mail API

Dec 22, 2014

This is the program i tried

package com.readAlerts;
import java.util.Properties;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.PasswordAuthentication;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;

[Code]...

But I am getting below error:

Exception in thread "main" java.lang.RuntimeException: javax.mail.MessagingException: Could not connect to SMTP host: smtp.gmail.com, port: 587;
nested exception is:
java.net.SocketException: Permission denied: connect
at com.readAlerts.SendEmailUsingGMailSMTP.main(SendEmailUsingGMailSMTP.java:63)
Caused by: javax.mail.MessagingException: Could not connect to SMTP host: smtp.gmail.com, port: 587;
nested exception is:

[Code]...

Tried every permutation and combination but all leading to this same error.

View Replies View Related

How To Send A Message To A Client

Jan 22, 2015

I want to send a message to a specific client in a server. This is my code and what I tried(I have only given you 3 classes in which I believe I have the problem).

TextClient:
import java.io.*;
import java.net.*;
import java.util.ArrayList;
import java.util.Scanner;
import java.util.concurrent.TimeUnit;
public class TextClient {
public TextClient() {

[Code]...

View Replies View Related

Servlets :: How To Send A Response Of A Map As A Json

Oct 5, 2014

@RequestMapping(value = { "/mapping" }, method = RequestMethod.GET)
@ResponseBody
public Map<A, List<B>> getAsByB(HttpServletRequest httpRequest) {
return map;
}

when i try to get it by url i get an error. how can i send a response of a map as a json ?

View Replies View Related

Servlets :: How To Send Request From One To Another Web Application

May 30, 2014

I have to send a request with post parameters from one web application to another web application,both are running different servers.

In my application i don't have any JSP,html only controller part which will handle request extract request parameters & based on request params i'll do a web service call.

My current requirement is based on request parameters i'll send request to another web application with received parameters.

I tried with sendRedirect() ,but it support only get() method.

how to proceed further.

View Replies View Related







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