| Communicating with a servlet using NIO? |
|
 |
Index ‹ java-programmer
|
- Previous
- 2
- Jars built with JDK 1.3 and JDK 1.4 interoperatingThe Runtime Environment is JRE 1.4. The latest code I have written has
been compiled with JDK 1.4. However it depends on some packages written
and compiled with JDK 1.3. Is there anything to look out for in this
kind of setup or should I have to recompile the older code with 1.4? I
have tested the whole thing and it works, but I wanted some more
information. It is a swing code and I need the JProgressBar's
indeterminate state which is available only in JDK 1.4.
Any update is welcome. If there is any document explaining the above,
that would be perfect. I searched but I was not able to find any
reference.
Thanks
JS
- 2
- Forcing System.gc()I have an app that, at one point, really bogs down as so many objects are
created and released in a lengthy process.
I am wondering if I may not be able to improve performance by System.gc() in
some "right" places in my code (wherever those might be!). It seems to me
though, that the gc facilities in Java are so good, that this is something
best left up to the JVM, and NOT mess with putting System.gc() in anyplace?
I am on WinXP / Vista and JRE 1.6.x. TIA, R. Vince
- 4
- My bean doesn't APPEAR on my JSP page!Hi, All!
I have this simple bean (below), and i make the .class using JBuilder 7.0.
I tryed to insert this bean into my JSP page:
<%@ page contentType="text/html; charset=windows-1251" %>
<html>
<head>
<title>
Jsp1
</title>
</head>
<jsp:useBean id="bean0" scope="session" class="bean1.KivaHanTester" />
<jsp:setProperty name="bean0" property="*" />
<body>
<h1>
JBuilder Generated JSP
</h1>
</body>
</html>
BUT I CAN't see this bean, when i open my JSP (IExplorer + Apache).
May be i need to init this bean, like init() or show() i don't know.
Thanks.
SOURCE CODE:
package bean1;
import java.awt.*;
public class KivaHan extends Canvas {
private String msg;
private int width, height;
public KivaHan () {
this ("Coffee: 10 lira");
}
public KivaHan (String s) {
this (s, 200, 200);
}
public KivaHan (String s, int width, int height) {
msg = s;
this.width = width;
this.height = height;
setForeground (Color.cyan);
setFont (new Font ("Serif", Font.ITALIC, 24));
setSize (getPreferredSize());
}
public void paint (Graphics g) {
Dimension d = getSize();
FontMetrics fm = g.getFontMetrics();
int len = fm.stringWidth (msg);
int x = Math.max (((d.width - len) / 2), 0);
int y = d.height / 2;
g.drawString (msg, x, y);
}
public Dimension getPreferredSize () {
return new Dimension (width, height);
}
}
package bean1;
public class KivaHanTester extends java.applet.Applet {
public void init () {
add (new KivaHan());
}
}
- 5
- How do i do if-else condition in Struts ?How do i do if-else condition in Struts ?
logic:equal does not do it . how struts tag could be used in the JSP
page for an if-else condition ?
how to do it ?
Can anybody provide an example ?
- 6
- Java GSM encoding from micHi
I'm trying to encode a microphone stream into GSM using
org.tritonus.lowlevel.gsm.Encoder but I am receiving just static noise -
I've checked the raw PCM output and it's fine. Is there anything obvious
that's missing here?
Thanks
__________________________
The mic is opened as:
AudioInputStream ais=null;
DataLine.Info info_mic = new DataLine.Info(TargetDataLine.class,
new AudioFormat(AudioFormat.Encoding.PCM_SIGNED, 8000.0f, 16, 1, 2,
8000.0f, false)
);
TargetDataLine mic = (TargetDataLine) AudioSystem.getLine(info_mic);
mic.open();
mic.start();
ais = new AudioInputStream(mic);
_____________________
And the GSM frame encoder is:
/*------*/
byte [] gsmframe(AudioInputStream ais){
byte [] encd = new byte[33];
try{
byte [] b = new byte[320];
ais.read(b,0,b.length);
DataInputStream di = new DataInputStream(new ByteArrayInputStream(b));
short [] buf = new short[160];
short j=0;
for(int k=0; k<buf.length; k++){
j=di.readShort();
buf[k]=j;
}
org.tritonus.lowlevel.gsm.Encoder enc = new
org.tritonus.lowlevel.gsm.Encoder();
enc.encode(buf, encd);
}catch(Exception e){
System.out.println("error with microphone reading "+e);
return null;
}
return encd;
}
/*-------*/
- 8
- jtreetabledear java professional,
i want to create a grid using jtreetable. i find the sample code in
the java.sun.com. but it is trickly to understand for me. do you
have any code
(simple code) for using the jtreetable ? i want to simple jtreetable
example program with sample data. do you have the code please send me
to my mail id
email***@***.com.
i also search in the net. but i only very less no. sample code related
to jtreetable. that code also so tricky. do you know any link that
contains simple
jtreetable program?
with regards,
balamurugan se
- 9
- batch update as a single transactionHi,
I'm doing a JDBC batch update, writing several thousand rows to a single
table. As I understand it a batch update can partially succeed, so some of
my rows might get written and some not. I'd like the batch update to either
fully succeed or completely fail, commit or rollback in other words. Is that
easy to do? I'm pretty new at this.
Thanks,
John
- 9
- Simple question for those who understand recursion well. Please help.I have a tree represented as a linked list of simple objects
(nodeId/parentId pairs) where the root node is the 1st element in the
list. The other nodes are in somewhat random order. The parentId refers
to the parent node.
I want to convert it into a list where the values are in pre-order.
I.e., I want to get this list as follows: ABCDEFGHIJ (see graph below).
I.e., get the 1st node, put in in the list. If it has children, go
through them one by one, get their child nodes, then put the parent in
the list, then the leftmost first, and go from there. I.e., so that
it's ordered in my linked list like this by (letters represent nodeId):
A
/ \
B J
/ | \
C H I
|
D
/|\
E F G
I created the following recursive method but it does not work
correctly. For example, it places the nodes A then B and then J into
the list first, rather than getting to J after adding all the child
nodes. "isOnTheList" checkes whether the item is already in the list.
"getImmediateChildren" returns the list of immediate child nodes
ordered by nodeId
Note: the empty list is passed to the method and is populated with the
result:
public static void orderTree(List list, List treeList) {
if(treeList == null || treeList.size() == 0)
return;
Node child = null; List children = null;
for(int i = 0; i < treeList.size(); i++) {
node = (Node) treeList.get(i);
// get list of children for this node
children = getImmediateChildren(node, treeList);
// if the node is not yet on the list, add it
if(! isOnTheList(node, list) )
list.add(cat);
// if it has children, recurse to add all other nodes
if(children.size() > 0) {
orderTree(list, children);
}
}
}
Any idea what the problem is?
Thanks.
- 10
- struts form population from an object model...flangelli wrote:
<snip>
> I have a business object model with attributes throughout that are
> mapped to different form beans. Every time that a form bean (jsp) is
> returned to the user's browser, I need to have a place to access my
> object model to retrieve the data from and populate the bean before it
> is displayed. So far it seems that the only time an action class is
> given "command" is AFTER the form submission, I need control on a page
> by page basis to retrieve the values from the object model into the
> bean so the jsp can render the beans values.....anyone had a problem
> similar to this? Thanks in advance - Flangelli
There's nothing which "requires" you to forward to a JSP; you could
just as easily forward to an action. The hitch here is that the
ActionForm will be populated according to the request parameters if
you just perform a forward. The solution is simply to specify
redirect="true" in the forwarding action so that the request
parameters get lost.
Just be careful in your validate method when using this mechanism:
you're users will be irked if the first time they see a page it
contains all manner of error messages. Since you often provide a
reset button on a form, the smart way to approach the situation is
to hold off generating errors if all form fields are blank (or
have the default value).
If this doesn't make perfect sense then repost and I'll dig up
some sample code. Or contact me off-line.
- 12
- extract numbers from picture?is this called pattern matching or AI in java? how can you extract a number
that is on a jpeg or bmp/gif/tiff ? is there any java package doing this?
thanks
- 14
- [Q] Saving imageI am looking for a solution to how to make a background image
permanent in a Java application.
My application can have a background image, but when it saves its
file, the background image is not included in the saved file. Is there
a convenient (or right) way to save a gif (or jpeg or png) image into
an application file?
Thanks in advance.
Young-Jin
- 14
- Eclipse vs NetBeans vs Jbuilder under LinuxHello everyone,
I've tried the above 3 IDEs in the last year and thought I might make some
comments and ask for your thoughts. Just for interest sake and please don't
start a Holy War ;-)
I originally used netBeans for development, but switched over to Jbuilder
because we where doing tomcat/struts development and my boss said it had
better support. I didn't really get to use netBeans struts stuff but it did
seem a bit weak in comparision.
I would have thought Borland would have a great editor, but I find it very
buggy in comparison to netBeans. Some of the things I have had problems
with include the cursor not being moved when you click in the text area
(this tends to screw up click and drag rearrangement of text or do it when
you don't mean too), auto-formatting of code rearranging it until it won't
compile, method parameter popups not always accessable, method parameter
popups not able to show the names of parameters - only the type, and some
others I can't remember right now.
However, the struts support in JBuilder does seem to be better than netBeans
and runs quite well. Over all the IDE also seems a little quicker and I
quite like the way that you can have multiple projects open and flip
between then with ease. netBeans doesn't seem to handle multiple projects
as smoothly as JBuilder.
I also tried Eclipse at home a couple of time in the last 6 months and at
the moment I can't see why many people are using it. On both occasions I
found also sorts of nasty bugs which tended to simple drive me nuts. The
last time time I used it for example, I found that it would not run the
code I had just edited. I.e. if I could load a project, made some changes
and hit the run button, it would run the code without the changes included.
In order to get the changes it, I had to explicitly do a save before each
run. This sounds trivial but can get very annoying, both netBeans and
JBuilder run the code you are editing, not the last saved code.
Eclipse also seemed to have a strange concept of projects. It looked rather
good with being able to see multiple project trees at the same time until
it came to running them. Then it appeared to separate the concept of
running a projects from the projects themselves and I had to effectively
re-setup again. I also found that if I had en error in one project, it
would fail the compile even if I was in another project. So whilst I could
have multiple projects open at a single time, it seemed to have trouble
understanding which projects I was in and what it was to compile. This
resulted in me having to unload/reload projects on a regular basis. I also
remember not being that happy with it's editor either, I can't remember
exactly why right now.
So, I would have to say that at the moment, I would tend to use netBeans for
general development, JBuilder for struts and Eclipse not at all.
--
cio
Derek
- 16
- Struts and AA based on a database
Hello:)
I have a question concerning authentification/authorization and
elements visibility on a Web page in Struts. How to manage the
visibility of control elements in a Struts-based application? The
information about users should be stored in a database and not in XML
configuration files. How to use role based or/and function based
authorization system and how to retrieve the rights from a database and
store them in the Principal object? The application is mantained within
Tomcat application server. So, how to do this? Or, being more precise,
is there any open-source library which provides such a functionality or
should I develop everything from scratch? Do you have some examples for
such stuff?
best regards,
Ania
- 16
- Re:Correct use of exceptionsWhen we talk about exception, it means that in some situation which we think
that it should works this way, but it isn't. For example, when we write
something to connect to remote SMTP server, we assume that the remote server
should be available but actually it is down... In this case, the exception
happened... So we need the exception handling to show our error message to
user and log the error.
Hope this helps!
Guoqi Zheng
http://www.big8reader.com
- 16
- Mp3 converter to WavHi,
I just need to convert a mp3 file to the Wav format.
Is there any free package existing, or do i have to write my own program ?
In that case, do you know any link that could help me to understand how to
do this ?
Thanks !
|
| Author |
Message |
Qu0ll

|
Posted: 2007-12-2 22:39:00 |
Top |
java-programmer, Communicating with a servlet using NIO?
Is it possible for a client applet to communicate with a servlet using NIO?
I know it's possible using standard IO but I would like to implement a
servlet that accepts NIO connections from clients and interacts with them.
Is this possible? I don't want to use a special port because of firewall
considerations.
--
And loving it,
-Q
_________________________________________________
email***@***.com
(Replace the "SixFour" with numbers to email me)
|
| |
|
| |
 |
Lew

|
Posted: 2007-12-2 23:12:00 |
Top |
java-programmer >> Communicating with a servlet using NIO?
Qu0ll wrote:
> Is it possible for a client applet to communicate with a servlet using
> NIO? I know it's possible using standard IO but I would like to
> implement a servlet that accepts NIO connections from clients and
> interacts with them. Is this possible? I don't want to use a special
> port because of firewall considerations.
The choice of NIO or the older IO packages is independent between client and
server. It's just a connection.
Likewise the port choice is independent of how you use the port once chosen.
You'll use whatever port you choose. You choose whatever port you'll use.
--
Lew
|
| |
|
| |
 |
Andrew Thompson

|
Posted: 2007-12-2 23:38:00 |
Top |
java-programmer >> Communicating with a servlet using NIO?
Lew wrote:
..
>Likewise the port choice is independent of how you use the port once chosen.
>You'll use whatever port you choose. You choose whatever port you'll use.
(A little out of my depth here*, but..) Would it not make most
sense to allow the end-user to select the (outgoing) port number
that best (dang well) suits them and their existing setup? [ Many
other apps. claim ports with no direct reference to the user's
wishes (probably according to clever algorithms that I would
prefer never to have to think/worry about). ]
Why would you do otherwise?
* My only minor messing with ports was in the Knock-Knock
server/client example - and of course, I leave it to the user to
decide what port numbers to use.
<http://www.physci.org/jws/#kk>
--
Andrew Thompson
http://www.physci.org/
Message posted via http://www.javakb.com
|
| |
|
| |
 |
Qu0ll

|
Posted: 2007-12-3 4:10:00 |
Top |
java-programmer >> Communicating with a servlet using NIO?
"Lew" <email***@***.com> wrote in message
news:email***@***.com...
> Qu0ll wrote:
>> Is it possible for a client applet to communicate with a servlet using
>> NIO? I know it's possible using standard IO but I would like to implement
>> a servlet that accepts NIO connections from clients and interacts with
>> them. Is this possible? I don't want to use a special port because of
>> firewall considerations.
>
> The choice of NIO or the older IO packages is independent between client
> and server. It's just a connection.
OK, but how do you do it exactly? What I'm trying to achieve is to do it
from an applet and not have the user have to select a port. The examples of
applet-2-servlet communication I can find use URLConnection but this only
has methods to get OutputStream etc. - nothing in relation to getting
SocketChannel or NIO-speak. Hence my original question as to whether it can
be done with NIO.
> Likewise the port choice is independent of how you use the port once
> chosen. You'll use whatever port you choose. You choose whatever port
> you'll use.
I want to use the same port that HTTP uses so that there are no issues with
firewalls having to approve connections.
--
And loving it,
-Q
_________________________________________________
email***@***.com
(Replace the "SixFour" with numbers to email me)
|
| |
|
| |
 |
Lew

|
Posted: 2007-12-3 5:47:00 |
Top |
java-programmer >> Communicating with a servlet using NIO?
Qu0ll wrote:
> OK, but how do you do it exactly? What I'm trying to achieve is to do
> it from an applet and not have the user have to select a port. The
> examples of applet-2-servlet communication I can find use URLConnection
> but this only has methods to get OutputStream etc. - nothing in relation
> to getting SocketChannel or NIO-speak. Hence my original question as to
> whether it can be done with NIO.
I suppose you could use the Socket class instead of URLConnection, but the
value of a channel on the client side is questionable. The point of NIO is to
multiplex several communications going through the same port. This will not
be an issue for a client. Why not just use the regular IO operations through
the URLConnection and just let the server do the NIO for its own sake?
What do you expect NIO will gain for you on the client side?
--
Lew
This post contained two requests for information.
|
| |
|
| |
 |
Qu0ll

|
Posted: 2007-12-3 5:57:00 |
Top |
java-programmer >> Communicating with a servlet using NIO?
"Lew" <email***@***.com> wrote in message
news:email***@***.com...
> Qu0ll wrote:
>> OK, but how do you do it exactly? What I'm trying to achieve is to do it
>> from an applet and not have the user have to select a port. The examples
>> of applet-2-servlet communication I can find use URLConnection but this
>> only has methods to get OutputStream etc. - nothing in relation to
>> getting SocketChannel or NIO-speak. Hence my original question as to
>> whether it can be done with NIO.
>
> I suppose you could use the Socket class instead of URLConnection, but the
> value of a channel on the client side is questionable. The point of NIO
> is to multiplex several communications going through the same port. This
> will not be an issue for a client. Why not just use the regular IO
> operations through the URLConnection and just let the server do the NIO
> for its own sake?
Are you saying that I could have standard IO at the client end and NIO at
the server end? I didn't realise you could mix them that way. Do you have
an example of how that would work or could you explain it in a bit more
detail?
> What do you expect NIO will gain for you on the client side?
Nothing really - I just thought that the client had to be NIO if the server
was NIO.
--
And loving it,
-Q
_________________________________________________
email***@***.com
(Replace the "SixFour" with numbers to email me)
|
| |
|
| |
 |
Owen Jacobson

|
Posted: 2007-12-3 6:56:00 |
Top |
java-programmer >> Communicating with a servlet using NIO?
On 2007-12-02 13:57:09 -0800, "Qu0ll" <email***@***.com> said:
> "Lew" <email***@***.com> wrote in message
> news:email***@***.com...
>> Qu0ll wrote:
>>> OK, but how do you do it exactly? What I'm trying to achieve is to do
>>> it from an applet and not have the user have to select a port. The
>>> examples of applet-2-servlet communication I can find use URLConnection
>>> but this only has methods to get OutputStream etc. - nothing in
>>> relation to getting SocketChannel or NIO-speak. Hence my original
>>> question as to whether it can be done with NIO.
>>
>> I suppose you could use the Socket class instead of URLConnection, but
>> the value of a channel on the client side is questionable. The point
>> of NIO is to multiplex several communications going through the same
>> port. This will not be an issue for a client. Why not just use the
>> regular IO operations through the URLConnection and just let the server
>> do the NIO for its own sake?
>
> Are you saying that I could have standard IO at the client end and NIO
> at the server end? I didn't realise you could mix them that way. Do
> you have an example of how that would work or could you explain it in a
> bit more detail?
>
>> What do you expect NIO will gain for you on the client side?
>
> Nothing really - I just thought that the client had to be NIO if the
> server was NIO.
Not at all. NIO is merely another way to talk to the IO subsystem of
the local host OS. Between hosts, it's all TCP/IP.
Once a sequence of bytes has been handed off to the OS to transmit over
a socket, there is nothing in that sequence of bytes identifying how it
was handed over; the stream {0x00, 0x01, 0x02, 0x03, ....} will look
identical to the receiver regardless of whether you use NIO to write it
or a Socket. What NIO does get you is the ability to multiplex IO
operations on a single thread. For applications with non-trivial
numbers of IO handles open at a time this matters; for programs that
only have one or two sockets, using a thread per socket is fine and
probably easier to read (if, possibly, harder to make thread-correct).
A client connecting to an NIO-based server would look identical to a
client connecting to any other server: new Socket ("192.168.0.1", 2700);
An NIO-based server accepting connections from a non-NIO client would
look identical to a server accepting connections from an NIO client:
someServerSocketChannel.accept ();
-o
|
| |
|
| |
 |
Nigel Wade

|
Posted: 2007-12-3 18:35:00 |
Top |
java-programmer >> Communicating with a servlet using NIO?
Qu0ll wrote:
> Is it possible for a client applet to communicate with a servlet using NIO?
> I know it's possible using standard IO but I would like to implement a
> servlet that accepts NIO connections from clients and interacts with them.
> Is this possible? I don't want to use a special port because of firewall
> considerations.
>
A real firewall should do deep packet inspection which will ensure that the
traffic which is going over the "http" port is actually HTTP protocol. They do
this with the specific intent of blocking this type of port "hijacking".
Of course, if the firewalls in question are not commercial grade border
firewalls then you will probably get away with it. If they are then you might
well be wasting your time.
--
Nigel Wade, System Administrator, Space Plasma Physics Group,
University of Leicester, Leicester, LE1 7RH, UK
E-mail : email***@***.com
Phone : +44 (0)116 2523548, Fax : +44 (0)116 2523555
|
| |
|
| |
 |
Lew

|
Posted: 2007-12-4 23:33:00 |
Top |
java-programmer >> Communicating with a servlet using NIO?
George Neuner wrote:
> Peer services sometimes do send from known ports to distinguish their
> own traffic from clients or other connection attempts, but in general
> it's rarely necessary to pick outgoing ports for your program.
Furthermore, tying down the client port reduces another degree of freedom for
the system. Architecturally a program should only lock down the degrees of
freedom that it absolutely must in order to function correctly. The more it
can tolerate from the environment, i.e., ignore, the more robust the system.
Leaving client-side port selection to the client is smart. Leaving
client-side behavior in general to the client is smart.
--
Lew
|
| |
|
| |
 |
Esmond Pitt

|
Posted: 2007-12-6 13:42:00 |
Top |
java-programmer >> Communicating with a servlet using NIO?
George Neuner wrote:
> constantly in a busy system. Not only do most programs let the system
> select outgoing ports, but the system also selects the incoming ports
> for most server programs.
This is not correct. TCP/IP uses the same port number as the listening
port for incoming connections.
> When a connection is made to a TCP
> listen port, the system selects a free port and transfers the incoming
> connection to it - all communication beyond the initial connection by
> the client takes place through that randomly assigned port.
This is not correct. See above.
|
| |
|
| |
 |
Lew

|
Posted: 2007-12-8 9:48:00 |
Top |
java-programmer >> Communicating with a servlet using NIO?
George Neuner wrote:
> On Thu, 06 Dec 2007 05:42:28 GMT, Esmond Pitt
> <email***@***.com> wrote:
>
>> George Neuner wrote:
>>
>>> constantly in a busy system. Not only do most programs let the system
>>> select outgoing ports, but the system also selects the incoming ports
>>> for most server programs.
>> This is not correct. TCP/IP uses the same port number as the listening
>> port for incoming connections.
>>
>>> When a connection is made to a TCP
>>> listen port, the system selects a free port and transfers the incoming
>>> connection to it - all communication beyond the initial connection by
>>> the client takes place through that randomly assigned port.
>> This is not correct. See above.
>
> Sorry, but it is you who are wrong. Look in your help or man pages
> for the description of the "accept" call.
>
> You may be thinking that sockets can be shared and multiplexed - which
> is true - but that's not how the accept call works.
>
>
> <QUOTE> from FreeBSD man page accept(2)
> Accept removes the next connection request from the queue (or waits
> until a connection request arrives), creates a new socket for the
> request, and returns the descriptor for the new socket. Accept only
> applies to stream sockets (e.g., those used with TCP).
> <\QUOTE>
All of these references say "creates a new socket", none say "assigns a new port".
--
Lew
|
| |
|
| |
 |
Lew

|
Posted: 2007-12-9 10:16:00 |
Top |
java-programmer >> Communicating with a servlet using NIO?
>> these references say "creates a new socket", none say "assigns a new port".
George Neuner wrote:
> Oh shit, you're right. Geez ... I don't know what the hell I was
> thinking. Sorry for the confusion.
George, you are a hero to me now. I am being serious, not sarcastic. I
praise you and laud you.
Lots of people make mistakes. I've made worse mistakes in these newsgroups
than this one. Your forthrightness is a good example. Also, we cannot learn
unless we are willing to admit mistakes and change direction.
Bravo, George!
--
Lew
|
| |
|
| |
 |
| |
 |
Index ‹ java-programmer |
- Next
- 1
- Need to know ASAPOur educational counselors are recruiting new people for our home degree program.
We are running this program as an experiment and we feel you may qualify. This program will earn you a fully qualified degree, with transcripts. Currently we are recruiting people with vast knowledge or experience in the field/trade of their choice.
Give our recruiting office a call when you have time.
Thanks
Alexander Piper
Office Number: 1-773-509-4920
We hope to be talking to you soon.
*We are taking calls at anytime in the day or evening.
--
To UNSUBSCRIBE, email to email***@***.com
with a subject of "unsubscribe". Trouble? Contact email***@***.com
- 2
- JDOM stringsHi All !
I have some xml file that contain next tag:
<text>ÐоÑ</text>
I get Element text = ... on this tag and want get string that it contain:
String myText = text.getText();
I hope to see in the myText : 0xD09D 0xD0BE .....
but get next set:
0xC390 0xC29D 0xC390 0xC2BE 0xC391 0xC280 0xC390 .... ?????
what is it 0xC390 ??? And how can I get that I want :) ???
--dima
- 3
- Drawing ImageHi,
I am developing a login application in which i need to have an image
put on to a JFrame which has several internal frames. (The main frame)
when I use the graphics object, it draws up the image and it disappears
in a few seconds.
I tried to change the background color, but i see only a flash of the
color and it disappears.
It would be extremely helpful is someone could sort this problem for
me.
Thank you,
Sumit
import javax.swing.*;
import java.awt.*;
import java.io.*;
import java.awt.event.*;
import javax.imageio.*;
import java.awt.Graphics.*;
public class Login extends JPanel implements KeyListener ,
ActionListener
{
JFrame mainFrame;
JDesktopPane desktop, background;
JInternalFrame user;
JButton ok, cancel;
JTextField userName;
TextField pass;
JLabel lname,lpass,message,ms;
JMenuBar mb;
JMenu start,view,options,insert,help;
JMenuItem ocm,ccm,print,exit,about;
Boolean connectionManagerStatus;
Image img;
Login()
{
/*
* Basic Theme
*/
try
{
UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
//UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel");
}
catch (Exception e)
{
System.out.println(e.toString());
}
/*
* Initializations and addition to the program
*/
mb = new JMenuBar();
desktop = new JDesktopPane();
background = new JDesktopPane();
mainFrame = new JFrame (".:: I . C . E ::. Application");
mainFrame.setJMenuBar(mb);
start = new JMenu ("Start");
view = new JMenu ("View");
options = new JMenu ("Options");
insert = new JMenu ("Insert");
help=new JMenu("help");
start.setMnemonic(KeyEvent.VK_S);
view.setMnemonic(KeyEvent.VK_V);
options.setMnemonic(KeyEvent.VK_O);
insert.setMnemonic(KeyEvent.VK_I);
help.setMnemonic(KeyEvent.VK_H);
mb.add(start);
mb.add(view);
mb.add(options);
mb.add(insert);
mb.add(help);
background.setVisible(true);
background.setSize(640,640);
ocm=new JMenuItem("Open Connection Manager",KeyEvent.VK_O);
ccm = new JMenuItem("Close Connection",KeyEvent.VK_C);
print = new JMenuItem("Print",KeyEvent.VK_P);
exit = new JMenuItem("Exit",KeyEvent.VK_X);
about = new JMenuItem("About Us",KeyEvent.VK_A);
start.add(ocm);
start.add(ccm);
start.addSeparator();
start.add(print);
start.add(exit);
help.add(about);
user = new JInternalFrame("Connection Manager");
lname = new JLabel("USERNAME:");
userName = new JTextField (50);
lpass = new JLabel("PASSWORD:");
pass = new TextField(50);
pass.setEchoChar('*');
ms = new JLabel ("Message From Server: ");
message = new JLabel("3 Wrong attempts and account freezes");
ok = new JButton ("Login");
cancel = new JButton ("Cancel");
ok.setBounds(20,180,100,20);
cancel.setBounds(130,180,100,20);
mainFrame.setUndecorated(false);
mainFrame.add(desktop);
mainFrame.setFocusable(true);
options.setEnabled(false);
insert.setEnabled(false);
view.setEnabled(false);
print.setEnabled(false);
ocm.setEnabled(false);
ccm.setEnabled(false);
connectionManagerStatus=true;
mainFrame.setSize(Toolkit.getDefaultToolkit().getScreenSize());
desktop.setSize(640,480);
lname.setBounds(10,40,70,20);
userName.setBounds(100,40,130,20);
lpass.setBounds(10,100,100,20);
pass.setBounds(100,100,130,20);
ms.setBounds(15,270,140,20);
message.setBounds(10,320,240,20);
message.setForeground(Color.darkGray);
user.setLayout(null);
user.getContentPane().add(lname);
user.getContentPane().add(userName);
user.getContentPane().add(lpass);
user.getContentPane().add(pass);
user.getContentPane().add(ok);
user.getContentPane().add(cancel);
user.getContentPane().add(ms);
user.getContentPane().add(message);
user.setResizable(false);
//JLabel s = new JLabel("XXXXXXXXXXXXXXx");
ok.setEnabled(false);
user.setVisible(true);
user.setSize(340,480);
desktop.setLocation(30,200);
desktop.add(user);
user.setLocation(30,200);
//user.setBorder(BorderFactory.createRaisedBevelBorder());
// adding listeners
userName.addKeyListener(this);
exit.addActionListener(this);
cancel.addActionListener(this);
ocm.addActionListener(this);
pass.addKeyListener(this);
ok.addActionListener(this);
mainFrame.setVisible(true);
mainFrame.validate();
l();
}
public void actionPerformed (ActionEvent ae)
{
if ((ae.getSource())==exit)
{
System.exit(0);
}
else if ((ae.getSource())==cancel)
{
user.setVisible(false);
userName.setText(null);
pass.setText(null);
ocm.setEnabled(true);
}
else if ((ae.getSource())==ocm)
{
user.setVisible(true);
ocm.setEnabled(false);
}
else if ((ae.getSource())==ok)
{
user.setVisible(false);
ocm.setEnabled(false);
ccm.setEnabled(true);
System.out.println(pass.getText());
}
}
public void keyPressed (KeyEvent ke)
{
if ((ke.getComponent())==userName)
{
if (userName.getText()!=null)
{
ok.setEnabled(true);
}
else
{
ok.setEnabled(false);
}
}
else if ((ke.getComponent())==pass)
{
}
}
public void keyReleased (KeyEvent ke1)
{
}
public void keyTyped (KeyEvent ke2)
{
}
public static void main (String args [])
{
Login obj = new Login ();
}
public void l()
{
Graphics g = mainFrame.getGraphics();
try
{
img = Toolkit.getDefaultToolkit().getImage("d:\\loge.bmp");
g.drawImage(img,1024,800,null);
System.out.println("Image drawn");
}
catch (Exception e)
{
System.out.println(e.toString());
}
}
}
- 4
- Vendor independent data sourceI have an application that I deployed to WebSphere using the default
Struts datasource from it's action. I've been reading about this now
and it sounds like this is not the prefered way to make a database
connection pool. They suggest using the containers, but I want to
remain vendor independent and be able to deploy my application in any
container with little or no changes.
I know there must be a standard non-vendor specific way to create a
connection pool. Can someone tell me what that standard is? Searching
the web just provided me with about 100 different ways to do it, but I
want the "Java Standard" way to do this.
Thanks,
Smitty
- 5
- Why jdk-1.5.0 and diablo-jdk-1.5.0 does not containOn Tue, Jan 08, 2008 at 01:04:22PM +0300, Alex Pivovarov wrote:
> Could you tell me why jdk-1.5.0 and diablo-jdk-1.5.0 does not contain
> sunpkcs11.jar in jre/lib/ext?
> Or I was doing something wrong when I install them. I use default options --
> the only think I uncheck is browser plugin.
Because the source code and build infrastructure aren't included for either
the JAR or the native library in the source that Sun distributes(*). You
could copy the included Linux/Solaris JARs over, but then you need to build
the corresponding native library somehow.
* - Actually, the source is there, but its bundled up and there is no
build infrastructure.
Thats my recollection at least.
--
Greg Lewis Email : email***@***.com
Eyes Beyond Web : http://www.eyesbeyond.com
Information Technology FreeBSD : email***@***.com
_______________________________________________
email***@***.com mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-java
To unsubscribe, send any mail to "email***@***.com"
- 6
- popupmenu for a cell in a JTableHello
I want to have a popupmenu when I right click on a selected cell in a JTable
(using with a AbtractTableModel). What are steps I should do, please help.
Thank you
S.Hoa
- 7
- problem faced while using setContentType("Application/csv")Hi.
while i am trying to respond my client with the dilaog using which a
client user could save the file , the file which is to be sent from
server .... i am facing some issues in
setContentType("Application/csv") .... (file type is csv) ... here is
the chunk of code ....
System.out.println("This line gets displayed before setting content
type");
httpservletresponse.setContentType("application/csv");
System.out.println("After setting content type") // This line never
gets displayed
httpservletresponse.setHeader("Content-Disposition","inline;
filename=" +strtemp[1]+".csv" );
try {
File uFile = new File(strFilePath);
int fSize = (int) uFile.length();
FileInputStream fis = new
FileInputStream(uFile);
PrintWriter pw =
httpservletresponse.getWriter();
int c = -1;
while ( (c = fis.read()) != -1) {
pw.print( (char) c);
}
// Close output and input resources.
fis.close();
pw.flush();
pw = null;
}
catch (Exception e) {
System.out.println("Exception is caught
");
e.printStackTrace();
Any suggestion regarding the issue will be highly obliged ...
Regards,
Madni
- 8
- JSP Include IssuesI have a web page using an include file. I am passing params to the
include page using jsp:param but am having some difficulty.
Locally (Windows PC/Tomcat Server, JBuilder) I can include ™ in
the heading1 param - when I put this live (Linux/Tomcat Server) the
heading1 text is cut off after the &. There is no error message from
Java (unless it is a System.out.print type error).
Does anyone have any suggestions as to why this is not working and how
I can resolve it?
<jsp:include flush="true" page="/inc/nav.jsp">
<jsp:param name="heading1" value="Business Web Design:
<em>Functional, Findable, Accessible ™</em>" />
<jsp:param name="pageTitle" value="Home" />
</jsp:include>
Regards,
Rick
www.e-connected.com
- 9
- Java inherited annotationsHello all!
Some times ago the problem was raised... I and my collegs started to
use Java annotations and noticed that our annotations those was made
for java interfaces and their methods didn't accessible in inherited
classes and interfaces... I tried to use the metatag @Inherited but IMHO
it doesn't work correctly. Anyway we have made our own realization of
inherited Java annotations and shared it. So u can use it if you want.
It is free and open source. Can be downloaded from here:
http://www.fusionsoft-online.com/annotation.php
Best Regards,
Michael Milonov
- 10
- Corba java apllet client communication problemI hava a problem with communication between Java/Corba server based on JDK
ORB with Java/Corba client (applet)
based on the same ORB. I`m using IOR to localize server.
client`s ORB i initialize like that:
Dane proxy = null;
ORB orb = ORB.init(parent, null);
org.omg.CORBA.Object obj = orb.string_to_object(sIOR);
proxy = DaneHelper.narrow(obj);
server`s ORB i initialize like that:
ORB orb = ORB.init(args, null);
POA rootpoa = POAHelper.narrow(orb.resolve_initial_references("RootPOA"));
rootpoa.the_POAManager().activate();
DaneImpl oDane = new DaneImpl();
org.omg.CORBA.Object ref = rootpoa.servant_to_reference(oDane);
String ior = orb.object_to_string(ref);
It looks like that:
- if i`m trying to run applet throught web site from the same (192.168.0.1)
computer where Corba sever works
everything works fine, i write it in the browser->
http://192.168.0.1//TestCoraba.html
- if i`m trying to run applet throught web site from an other (192.168.0.2)
computer server receive method call
from client but client can`t receive server`s answer and stops, i write it
in the browser-> http://192.168.0.1//TestCoraba.html
Maybe you what i`m doing wrong.
Thanks form any help.
Best Regards - gRabbi
- 11
- Tomcat, Oracle, connection pooling, BLOBsI have a rather strange problem with Tomcat's connection pooling and
the Oracle JDBC driver when using BLOBs that seems to be related to
class loading.
My configuration:
Tomcat 5.0.27
Oracle 9i
ojdbc14.jar is in $CATALINA_HOME/common/lib (and nowhere else)
The datasource is configured in server.xml
Everything works perfectly as long as I don't configure the datasource
in the server.xml file (including reading/writing BLOBs).
Once I use the datasource configuration in server.xml everything
except Oracle's BLOB implementation works (means: I can access the
tables, insert, select etc., but I can't read/write BLOBs)).
The problem is with class loading:
System.out.println(getConnection() instanceof
oracle.jdbc.driver.OracleConnection);
System.out.println(getConnection().getClass().getName());
results in:
false
oracle.jdbc.driver.OracleConnection
So the connection is of the expected type, but the type has been
loaded with the wrong class loader. This leads to a ClassCastException
in the Oracle JDBC driver (createTemporary()).
As I told you the JDBC driver is in common/lib and nowhere else, so
the class should be available in the application code.
Any hints ?
- 12
- CeWolf and JSPHi, I'm Claudio, I'm a student and I want to use ceWolf for my graphs
in JSP pages. I visited the web site http://cewolf.sourceforge.net/
and i followed each pass of the tutorial but I don't visualize the
chart, there is an exeption: NullPointerException in cewolf_jsp.java
row 202:
int _jspx_eval_cewolf_img_0 = _jspx_th_cewolf_img_0.doStartTag();
In the JSP, if I delete this row:
<cewolf:img chartid="line" renderer="cewolf" width="400"
height="300"/>
all go ok, but obviously there isn't the chart.
Could you help me, please!
Thanks, Claudio
- 13
- Why is creating a simple component with Netbeans IDE fails with an exceptionHi
steps:
using a mounted sub-directory named TESTING
Template: In the Explorer, select the TESTING node and choose File New "Java
Gui Form" Bean Form. click next
Target Location: In Name enter TargetName. click next
Basic Class definition: Superclass select javx.swing.JComponent. click
finish
Why do you get an exception :
Cannot determine form type (javax.swing.JComponent)
Please make sure the class is a JavaBean
The form cannot be opened.
I am trying to build a component similar to a JLabel which is a JavaBean
derived directly from a JComponent.
Which step is missing or am I completly out to lunch.
Thanks in advance
Andre
- 14
- Help using TexPadIs there anyone here who knows how to use TextPad for a programming editor?
I sure could use the help. The instructions in help don't really explain
what to do. It says I'm supposed to see something but it isn't there, i.e.
I'm supposed to click on "Configure" then "Tools" then "Add" and I'm
supposed to click on "Java SDK Commands" and that command is not listed.
What do I do??
Thanks
Pete
- 15
- Snake Sex 1827email***@***.com wrote:
> I like to masterbate with my pet python, i hope you enjoy the pics i posted here of me having a wonerfull snakey time !
>
> http://superbabes.sexpartnerbd.com
> cvgixlemtdskrblgjgfeitxfscjzhrcppyxghjowcxfo
>
leave it out! this is a java programming news group!
try comp.lang.python
W'ell just hang here having a wonderful erm.... "Classy" time! [groan]
|
|
|