 |
 |
Index ‹ java-programmer
|
- Previous
- 2
- XML call XSL that calls xml through document() elementHello,
I am trying to create an XML document on the fly that sends some
parameters to an xsl document which calls the correct xml document that
corresponds to the parameters.
I reference the xsl document:
<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="web-primary.xsl"?>
I am just trying to hardcode the request to prove that this is possible
for the time being so the parameters are already in the xsl that will
eventually be variables.
but I am unsure what else to include in the first XML file to make the
call to the web-primary.xsl????? My XSL is complete and the
corresponding XSL files are complete.
The xsl doc has a document element that calls the correct xml file that
contains the data.
My reason for doing all of this is because Firefox will not allow me to
go to a remote xml file from the server so I want the browser to do the
work of getting the remote xml file. If you have a better way of doing
this, please let me know.
thx.
- 3
- Array of generic List?Hello,
I am new to 1.5 and thus generics. I have read the generic tutorial and
a decent number of websites/newsgroup posts on the subject. But I still
cannot find a satisfactory solution to the following (as of now the
best I've got is an unchecked conversion warning)
The code below does not compile, but I think it shows to a human what I
want to accomplish. I can't seem to find the proper syntax and use of
generics to accomplish this without a warning. Any help and reasoning
why I need to do whatever the solution is would be great. Thanks.
public class MyClass {
private List<Foo>[] myFoos;
public MyClass() {
myFoos = new List<Foo>[5];
}
public void addFoo(int index, Foo foo) {
myFoos[index].add(foo);
}
}
- 4
- 8
- Need help creating a program to create sudukoStill a little rough at this language but i need to create a program
for my class. Was wanting to create a java program that makes sudukos.
It doesn't need a GUI or anything like that just ouput to a txt file
ot to the screen. I would appreciate any help or direction.
- 8
- Novice Form QuestionI am a novice at JSP / HTML and have a Forms releated question. I am
really looking for sample code I can leverage to help understand how
to address non-trivial form layouts.
I undestand the how to build a -simple- form with a few input fields
and process this with JSP - Struts interaction. Unfortunately, I am
weak in HTML / JavaScript and I need to understand and build a more
complicated form.
Basically my form must look something like this:
User Name: _________________ Baggage Type ____________
Add Button | Remove Button Add Button | Remove Button
---------------------------- -------------------------
| Tom | | SomeBagType 1 |
| Dick | | SomeBagType 2 |
| Harry | | SomeBagType 3 |
| Jane | | SomeBagType 4 |
| | | |
---------------------------- -------------------------
Submit Button Cancel Button
Note that there are 6 buttons on the form. The Add / Remove buttons
are intended to allow the user to Add or Remove -User name's- or
-Baggage Type's- before the form is submitted.
I am not sure how to handle this. My guess is that Javascript might
work ( I do Java but not JavaScript :-( ) but I am open to suggestions
and most importantly EXAMPLES of how this might be implemented.
This code will part of a JSP-Struts project.
Thanks.
- 9
- Java server performance - jeetyHi All,
I am working on an application where a servlet need to handle min 600
request / sec(which will keep on increasing in future)
So I am not able to decide which application server I should use.
As I go through some benchmarks I came to know that Jetty's performance
is better but
I don't know how much load it can handle.
Is there any who has used Jetty on heavy traffic application?
or is there any another servlet container / HTTP Server which can
handle such a load
Plz suggest me.
Thanks in Advance.
Rajiv Girdhar
- 12
- Saving canvasHi. I have a problem with saving canvas to file. All over net there
are faqs on how to save a NEW canvas to file (after drawing on it). I
have a canvas, what should i do in order to save what's currently on
it to a file?
- 13
- Question on the flush methodAccording to Sun's web site, the flush method of the OutputStream object
does nothing.
So, what does actually happens when you call it?
At times I may see different behavior when including it within a program
(some times a socket read error) which I would think is strange esspecially
if the method is not supposed to do anything.
Any ideas?
- 14
- 14
- Anyone seen this problemMaybe I am being stupid, but I am having difficulty getting mouse events
from a custom JComponent. At this point I have put an instance of a subclass
of JComponent in a JScrollPane and placed it in the center of a
BorderLayout. I then added a mouse listener to the subclass of JComponent,
traced through the code to make sure I am acutally adding the listener, but
my mouseClicked(), mousePressed() and mouseReleased() methods on my listener
class are not called. Any one seen this problem before.
- 15
- internet address vs lanI am about to create a RPC program and I need a servlet to talk to a
server. The servlet is running on the internet, the server is running
on a lan computer. I am pretty sure that the lan ip address is behind
our firewall. Can I still communicate with the server through RPC.
Berlin Brown
email***@***.com
this question sounds confusing, doesnt it?
- 16
- thin java cient?Hello, please, I'm searching for a Thin Java Client, for J2EE.
I want to build a thin java swing client.
How to do it?
tks
Programador
----------------------------------
email***@***.com
- 16
- 16
- Java securityI havean applet that connects to Oracle osing the thin client. It
works when run from IDE. When I try to load it into a web browser I
get
java.security.AccessControlException: access denied
(java.util.PropertyPermission oracle.jserver.version read)
What's up?
- 16
- Java program helpHello everyone, I need your help.. can you check why did i commit an
error on the n=System.read("enter numer:"); part...? Thanks in
advance...
By the way, the program will run as follows:
the user will input a number, and the program will generate the
fibonacci series based on the number. if example user input is 4,
there should be four series of fibonacci...:)
public class fibonacci
{
public static void main(String args[])
{
int prev1 = 1, prev2 = 1, current = 1;int n;
n = System.read("enter number: ");
for (int i = 3; i <= n; i++)
{
current += prev2;
prev2 = prev1;
prev1 = current;
System.out.println(" " + current);
}
}
}
|
| Author |
Message |
henry.lo

|
Posted: 2003-10-4 6:45:00 |
Top |
java-programmer, java.nio problem
I had a NIO problem.
I tried to open a socket channel, and grep a HTML page from HTTP GET.
I did it success if I open and close socket channel everytime I send a
request and get the response.
However, if I keep open the socket channel and send multiple requests,
I'll get IOException.
Does anybody know how to solve this problem? Thanks in advance!
Note: I don't want to fire requests in parallel but one by one
sample code:
=============================================================
private Charset charset = Charset.forName("ISO-8859-1");
private SocketChannel channel;
try
{
// do connection
InetSocketAddress socketAddress =
new InetSocketAddress( "www.mydomain.com", 80);
channel = SocketChannel.open(socketAddress);
// send request #1
channel.write(charset.encode("GET /page1.html HTTP/1.0\r\n\r\n") );
// read response #1
ByteBuffer buffer = ByteBuffer.allocate(1024);
while ((channel.read(buffer)) != -1)
{
buffer.flip();
System.out.println(charset.decode(buffer));
buffer.clear();
}
// send request #2
channel.write(charset.encode("GET /page2.html HTTP/1.0\r\n\r\n") );
// read response #2
// program threw "java.io.IOException: Read failed" error
while ((channel.read(buffer)) != -1)
{
buffer.flip();
System.out.println(charset.decode(buffer));
buffer.clear();
}
}
catch (IOException e)
{
e.printStackTrace();
}
finally
{
if (channel != null)
{
try
{
channel.close();
} catch (IOException e) {}
}
}
=============================================================
|
| |
|
| |
 |
Dave Schaumann

|
Posted: 2003-10-4 7:00:00 |
Top |
java-programmer >> java.nio problem
Henry wrote:
> channel.write(charset.encode("GET /page1.html HTTP/1.0\r\n\r\n") );
Disclaimer: I am not an expert on HTTP, but
-- you should include a "Host: www.mydomain.com" header (modified for
the host of each request, of course).
-- you'll need to check the RFC to be sure, but I think HTTP/1.0
closes the connection by default after each request. Try adding
a "Connection: keep-alive" header to your request.
|
| |
|
| |
 |
VK

|
Posted: 2003-10-4 7:19:00 |
Top |
java-programmer >> java.nio problem
Actually this is how HTTP supposes to work: a page with 2 pictures on it for
example requires 3 separate requests (for page itself and for 2 pictures on
it). "Serve request/close connection".
"keep-alive" option is a server-side setting. If server doesn't support it,
you cannot force it to. (IMHO)
If you are dealing with your own server, maybe you want to use FTP instead?
Henry <email***@***.com> wrote in message
news:email***@***.com...
> I had a NIO problem.
> I tried to open a socket channel, and grep a HTML page from HTTP GET.
> I did it success if I open and close socket channel everytime I send a
> request and get the response.
> However, if I keep open the socket channel and send multiple requests,
> I'll get IOException.
> Does anybody know how to solve this problem? Thanks in advance!
> Note: I don't want to fire requests in parallel but one by one
> sample code:
> =============================================================
> private Charset charset = Charset.forName("ISO-8859-1");
> private SocketChannel channel;
> try
> {
> // do connection
> InetSocketAddress socketAddress =
> new InetSocketAddress( "www.mydomain.com", 80);
> channel = SocketChannel.open(socketAddress);
>
> // send request #1
> channel.write(charset.encode("GET /page1.html HTTP/1.0\r\n\r\n") );
> // read response #1
> ByteBuffer buffer = ByteBuffer.allocate(1024);
> while ((channel.read(buffer)) != -1)
> {
> buffer.flip();
> System.out.println(charset.decode(buffer));
> buffer.clear();
> }
>
> // send request #2
> channel.write(charset.encode("GET /page2.html HTTP/1.0\r\n\r\n") );
> // read response #2
> // program threw "java.io.IOException: Read failed" error
> while ((channel.read(buffer)) != -1)
> {
> buffer.flip();
> System.out.println(charset.decode(buffer));
> buffer.clear();
> }
> }
> catch (IOException e)
> {
> e.printStackTrace();
> }
> finally
> {
> if (channel != null)
> {
> try
> {
> channel.close();
> } catch (IOException e) {}
> }
> }
> =============================================================
|
| |
|
| |
 |
d94-rol

|
Posted: 2003-10-4 17:15:00 |
Top |
java-programmer >> java.nio problem
VK (email***@***.com) wrote:
: Actually this is how HTTP supposes to work: a page with 2 pictures on it for
: example requires 3 separate requests (for page itself and for 2 pictures on
: it). "Serve request/close connection".
: "keep-alive" option is a server-side setting.
Not true anymore. HTTP/1.0 closes the connection after each served
request as default. Some clients and server have keep-alive
implemented.
For HTTP/1.1 (rfc 2616) persistent connections are the default and a
client that issues a HTTP/1.1 request does not need to send any
keep-alive header (the server already knows that the client supports
it).
Since all compliant HTTP/1.1 devices have support for the chunked
encoding nearly all requests can actually be served by one
connection.
/robo
|
| |
|
| |
 |
| |
 |
Index ‹ java-programmer |
- Next
- 1
- ports/77656: java/jdk15 - (AMD64) install problem.Synopsis: java/jdk15 - (AMD64) install problem.
State-Changed-From-To: open->feedback
State-Changed-By: linimon
State-Changed-When: Fri Mar 31 08:53:35 UTC 2006
State-Changed-Why:
Submitter: is this still a problem?
Responsible-Changed-From-To: phantom->freebsd-java
Responsible-Changed-By: linimon
Responsible-Changed-When: Fri Mar 31 08:53:35 UTC 2006
Responsible-Changed-Why:
Reassign from phantom since he has been inactive for more than one year.
Hat: gnats-admin
http://www.freebsd.org/cgi/query-pr.cgi?pr=77656
- 2
- Is this syntactically valid Java?Is the following syntactically valid?
public class Foo {
public static void main(String[] args) {
for( foo: ; ; ); // Note statement label
}
}
javac is rejecting this, but IntelliJ is saying that it is valid. I
would appreciate a reference to the JLS if possible, so I can file a
bug report either with Sun or with JetBrains.
--
C. Benson Manica | I appreciate all corrections, polite or otherwise.
cbmanica(at)gmail.com |
----------------------| I do not currently read any posts posted through
sdf.lonestar.org | Google groups, due to rampant unchecked spam.
- 3
- why call cipher.getInstance(),throw below error?my source code is:
Security.addProvider(new BouncyCastleProvider());
Cipher cipher = Cipher.getInstance("RSA/NONE/PKCS1PADDING","BC");
when run it , cause below error,who can explain it,thanks in
advance.....
java.lang.ExceptionInInitializerError
at java.lang.Class.runStaticInitializers(Unknown Source)
at javax.crypto.Cipher.a(Unknown Source)
at javax.crypto.Cipher.getInstance(Unknown Source)
at
com.pioneer.bluray.security.authenticator.SignatureChecking.rsaDecrypt(Unknown
Source)
at
com.pioneer.bluray.security.authenticator.SignatureChecking.fetchSignature(Unknown
Source)
at
com.pioneer.bluray.security.authenticator.SignatureChecking.checkCredentialValues(Unknown
Source)
at
com.pioneer.bluray.security.authenticator.SignatureChecking.checkCredentials(Unknown
Source)
at
com.pioneer.bluray.security.authenticator.DVBSecUtils.invokeSecurity(Unknown
Source)
at org.dvb.lang.DVBClassLoader.securityCheck(Unknown Source)
at org.dvb.lang.DVBClassLoader.acquireData(Unknown Source)
at org.dvb.lang.DVBClassLoader.defineClassPrivileged(Unknown
Source)
at org.dvb.lang.DVBClassLoader.access$000(Unknown Source)
at org.dvb.lang.DVBClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Unknown Source)
at org.dvb.lang.DVBClassLoader.findClass(Unknown Source)
at org.dvb.lang.DVBClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at com.sun.tv.Request.execReq(Unknown Source)
at com.sun.tv.XletRunnable$ExecThread.run(Unknown Source)
at java.lang.Thread.startup(Unknown Source)
Caused by: java.lang.SecurityException: Cannot set up certs for
trusted CAs
at javax.crypto.SunJCE_b.<clinit>(Unknown Source)
... 20 more
Caused by: java.lang.SecurityException: Jurisdiction policy files
are not signed by trusted signers!
at javax.crypto.SunJCE_b.f(Unknown Source)
at javax.crypto.SunJCE_b.e(Unknown Source)
at javax.crypto.SunJCE_s.run(Unknown Source)
at java.security.AccessController.doPrivileged(Unknown Source)
at java.security.AccessController.doPrivileged(Unknown Source)
... 21 more
- 4
- Problem with JDBC-ODBC connection to MS Access 2000I am trying to use JDBC-ODBC bridge to connect to a Access 2000
database on a Windows 2000 machine. I have set up
the database using the Data Sources utility in Windows 2000. I am
using the Java(TM) 2 SDK, Standard Edition
Version 1.4.2_01. The code snippet from an example I found is:
import java.sql.*;
import javax.swing.JOptionPane;
public class BookDB{
private static Connection connection;
private static Statement scrollStatement;
private static ResultSet books;
public static void connect() throws ClassNotFoundException,
SQLException {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String url = "jdbc:odbc:MurachBooks";
String user = "Admin";
String password = "";
connection = DriverManager.getConnection(url, user, password);
}
When I complie I get the following error:
BookDB.java [10:1] cannot resolve symbol
symbol : method forName (java.lang.String)
location: class Class
try {Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
^
1 error
Errors compiling BookDB.
I have looked at all of the possible sources of information I can
think of to find an answer to my problem.
- 5
- Writing and running files from a Java/AspectJ application.I'm creating an add-on to windows that will let me create files and run
basic functions such a image editing, both built in and on the hard
drive of a ftp server. If anyone could help me it would be wonderful.
I am planning to use the Eclispe SDK woth the AspectJ plugin. I have
the basic functions set up word editing but I need to know how to run
.exe files on the hard drive.
- 6
- 7
- Applet startup error - simple questionGreetings!
I am running into a very strange problem with a very simple code
In my html page I have the following code:
<applet codebase="/" code="InterApplet" width="400" height="150"
name="InterApplet">
<param name="OutFrame" value="outFrame" valuetype="object">
no support for java
</applet>
When I load the page on Windows 2000 machine running IE6 it works fine
- applet loads. However, when I try to open this page on a Windows XP
machine also running IE6 it can't find the applet "load: class
InterApplet not found". I have my custom built web server so I could
actually see that the browser did make a request for InterApplet.class
and web server has served it.
So what in the world is happening?!? This is very frustrating.
I have not done any serious java programming since '97...
Thanks for your time.
- 8
- java.lang.OutOfMemory ErrorI had used StringBuffer, as with 'out.println()' I will have to use +
operator for all the concatenation which I thought won't be that
efficient as using the StringBuffer.
- 9
- SPOT smart sensorsFor anyone interested in these but could never get the willpower to
learn embedded C or somesuch arcane language, these kits from Sun just
came out:
http://www.sunspotworld.com/products/
Some info:
http://www.sunspotworld.com/docs/
I had tinkered around with these typrs of objects before, but having
the thing programmable in Java makes the entire thing easier on my
end :-)
- 10
- Client/Server chat program - wait for connectionHi,
I'm trying to modify a client/server chat program that connects
immediately, to wait till an IP address is selected from a combo box and
then connect when a connect button is pressed. The combo box is loaded
from a file of IP addresses and I select the localhost address of
127.0.0.1.
I've taken out the app.runClient line from the main class and made it
the actionPerformed when the connect button is pressed, but the client
side seems to go dead (won't accept any input) when I do this although
the connection seems to be working.
Any help appreciated.
// Client.java
// Set up a Client that will read information sent
// from a Server and display the information.
import java.io.*;
import java.net.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Client3 extends JFrame
{ private JTextField enter;
private JTextArea display;
private JButton connect, send;
private JComboBox selectIp;
ObjectOutputStream output;
ObjectInputStream input;
String message = "", address = "";
public Client3()
{
super( "Client" );
Container c = getContentPane();
JPanel northPanel = new JPanel();
northPanel.setLayout( new GridLayout( 2, 1, 3, 3 ) );
// Enter field and action listener
enter = new JTextField();
enter.setEnabled( false );
enter.addActionListener(
new ActionListener() {
public void actionPerformed( ActionEvent e )
{
sendData( e.getActionCommand() );
}
}
);
northPanel.add( enter );
// Send button
send = new JButton("Send >");
send.addActionListener(
new ActionListener()
{
public void actionPerformed( ActionEvent e )
{
sendBtn( e.getActionCommand() );
}
}
);
northPanel.add( send );
c.add( northPanel, BorderLayout.NORTH );
// Dislay area
display = new JTextArea();
c.add( new JScrollPane( display ),
BorderLayout.CENTER );
JPanel southPanel = new JPanel();
southPanel.setLayout( new GridLayout( 1, 2, 3, 3 ) );
// SelectIP combobox, listener and item listener
selectIp = new JComboBox();
selectIp.addItemListener(
new ItemListener() {
public void itemStateChanged( ItemEvent evt )
{
if( evt.getSource() == selectIp )
if( evt.getStateChange() == ItemEvent.SELECTED )
address = (String) evt.getItem();
}
} );
southPanel.add( selectIp );
// Read file and load into combobox
try
{
BufferedReader inBuffer = new BufferedReader( new
FileReader("ipaddress.txt") );
String line = inBuffer.readLine();
while( line != null )
{
selectIp.addItem( line );
line = inBuffer.readLine();
}
inBuffer.close();
}
catch(IOException e)
{ System.out.println(e);
}
// Connect button
connect = new JButton( "Connect");
connect.addActionListener(
new ActionListener() {
public void actionPerformed( ActionEvent e )
{
if( e.getSource() == connect )
{
runClient();
}
}
} );
southPanel.add( connect );
c.add( southPanel, BorderLayout.SOUTH );
setSize( 300, 300 );
show();
} // end Client constructor
public void runClient()
{ Socket client;
try {
// Step 1: Create a Socket to make connection.
display.setText( "Attempting connection\n" );
client = new Socket(
InetAddress.getByName( address ), 6000 );
display.setText( "Connected to: "+ address +
client.getInetAddress().getHostName() );
// Step 2: Get the input and output streams.
output = new ObjectOutputStream(
client.getOutputStream() );
output.flush();
input = new ObjectInputStream(
client.getInputStream() );
display.append( "\nGot I/O streams" );
// Step 3: Process connection.
enter.setEnabled( true );
do
{ try {
message = (String) input.readObject();
display.append( "\n" + message );
display.setCaretPosition(
display.getText().length() );
}
catch ( ClassNotFoundException cnfex ) {
display.append(
"\nUnknown object type received" );
}
} while ( !message.equals( "SERVER>>> quit" ));
// Step 4: Close connection.
display.append( "\nClosing connection.\n" );
output.close();
input.close();
client.close();
} // end try
catch ( EOFException eof ) {
System.out.println( "Server terminated connection" );
}
catch ( IOException e ) {
e.printStackTrace();
}
} // end runClient
// Action handler for Enter key
private void sendData( String s )
{
try {
message = s;
output.writeObject( "CLIENT>>> " + s );
output.flush();
display.append( "\nCLIENT>>>" + s );
}
catch ( IOException cnfex ) {
display.append(
"\nError writing object" );
}
} // end sendData
// Action handler for send button
private void sendBtn( String s )
{
try {
s = enter.getText();
output.writeObject( "SERVER>>> " + s );
output.flush();
display.append( "\nSERVER>>>" + s );
}
catch ( IOException cnfex ) {
display.append(
"\nError writing object" );
}
} // end sendBtn
// Main
public static void main( String args[] )
{
Client3 app = new Client3();
app.addWindowListener(
new WindowAdapter()
{
public void windowClosing( WindowEvent e )
{ System.exit( 0 );
}
}
);
// app.runClient();
} // end main
} // end Client Class
// Server.java
// Set up a Server that will receive a connection
// from a client, send a string to the client,
// and close the connection.
import java.io.*;
import java.net.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Server1 extends JFrame
{
private JTextField enter;
private JTextArea display;
ObjectOutputStream output;
ObjectInputStream input;
public Server1()
{
super( "Server" );
Container c = getContentPane();
enter = new JTextField();
enter.setEnabled( false );
enter.addActionListener(
new ActionListener()
{
public void actionPerformed( ActionEvent e )
{
sendData( e.getActionCommand() );
}
}
);
c.add( enter, BorderLayout.NORTH );
display = new JTextArea();
c.add( new JScrollPane( display ),
BorderLayout.CENTER );
setSize( 300, 300 );
show();
} // end Server constructor
public void runServer()
{
ServerSocket server;
Socket connection;
int counter = 1, optionPane;
try {
// Create a ServerSocket.
server = new ServerSocket( 6000, 100 );
while ( true )
{
// Wait for a connection.
display.setText( "Waiting for connection\n" );
connection = server.accept();
display.append( "Connection " + counter +
" received from: " +
connection.getInetAddress().getHostName() );
// Set input and output streams.
output = new ObjectOutputStream(
connection.getOutputStream() );
output.flush();
input = new ObjectInputStream(
connection.getInputStream() );
display.append( "\nGot I/O streams\n" );
// Process connection.
String message =
"SERVER>>> Connection successful\n";
output.writeObject( message );
output.flush();
enter.setEnabled( true );
do {
try {
message = (String) input.readObject();
display.append( "\n" + message );
display.setCaretPosition(
display.getText().length() );
}
catch ( ClassNotFoundException cnfex ) {
display.append(
"\nUnknown object type received" );
}
if( message.equals( "CLIENT>>> TRANSFER FILE?" ) )
{
optionPane = JOptionPane.showConfirmDialog((Component)
null, "Do you want to accept the file transfer",
"File Transfer", JOptionPane.YES_NO_OPTION );
if( optionPane == JOptionPane.YES_NO_OPTION )
{
output.writeObject( "PRESS 'SEND FILE' BUTTON" );
output.flush();
display.append( "\nWAITING FOR FILE" );
}
else
{
output.writeObject( "NO - Do not send file" );
output.flush();
display.append( "\nNO - Do not send file" );
}
}
} while ( !message.equals( "CLIENT>>> quit" ) );
// Close connection.
display.append( "\nUser terminated connection" );
enter.setEnabled( false );
output.close();
input.close();
connection.close();
++counter;
} // end while
} // end try
catch ( EOFException eof ) {
System.out.println( "Client terminated connection" );
}
catch ( IOException io ) {
io.printStackTrace();
}
} // end runServer
private void sendData( String s )
{
try {
output.writeObject( "SERVER>>> " + s );
output.flush();
display.append( "\nSERVER>>>" + s );
}
catch ( IOException cnfex ) {
display.append(
"\nError writing object" );
}
} // end sendData
public static void main( String args[] )
{
Server1 app = new Server1();
app.addWindowListener(
new WindowAdapter()
{
public void windowClosing( WindowEvent e )
{ System.exit( 0 );
}
}
);
app.runServer();
} // end main
} // end Server Class
- 11
- 12
- 13
- Having issues with context listener and netbeansI'm new to netbeans and the whole JSP world in general (i have
experience in j2me and the j2se). I basically wanted to test out the
listener functions.
I get no errors with the following code, however, i'm also not able to
'break' where i want to be able to and I have no output as I would
expect. Any suggestions would be great.
MyHttpSessionListener.java
-------------------------------------------------------------
package com.maturitymodel;
import javax.servlet.http.HttpSessionListener;
import javax.servlet.http.HttpSessionEvent;
public class MyHttpSessionListener implements HttpSessionListener
{
public void sessionCreated(HttpSessionEvent e)
{
System.err.println("Hello new session");
}
public void sessionDestroyed(HttpSessionEvent e)
{
System.err.println("ByeBye old session");
}
}
---------------------------------------------------------------------------
web.xml
--------------------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<context-param>
<param-name>com.sun.faces.verifyObjects</param-name>
<param-value>false</param-value>
</context-param>
<context-param>
<param-name>com.sun.faces.validateXml</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>javax.faces.CONFIG_FILES</param-name>
<param-value>/WEB-INF/faces-config.xml</param-value>
</context-param>
<context-param>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>client</param-value>
</context-param>
<listener>
<listener-class>com.maturitymodel.MyHttpSessionListener</listener-class>
</listener>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>
<session-config><session-timeout>
30
</session-timeout></session-config><welcome-file-list><welcome-file>
index.jsp
</welcome-file></welcome-file-list></web-app>
-----------------------------------------------------------------------
index.jsp
------------------------------------------------------------------------
<%@ page session="true"%>
- 14
- 2 level RAMAt some it will be economic to create banks of say 10 gigabytes of
RAM. This ram will be slower than regular RAM, but won't lose its
value when the power is ostensibly off.
How will this be integrated into Java?
The Windows world will likely treat these as small disk drives. You
will be able to manually place important files there. Windows will
fill it with something useless like system recovery snapshots.
However, it could be used more cleverly.
1. as a cache, much like the old Univac 1106 migrated files between
various speeds of mass storage in order to keep the most commonly used
ones on the fastest devices. You might even, like the 1106 unify this
with backup, so all files got backed up to servers on the Internet, or
spilled there if the disk became full.
2. for large address spaces, to keep infrequently used objects. It
becomes like your swap file today.
3. something else.
--
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com
- 15
- storing SecretKey in keystorehi
i created a keystore as below
public static void makeKeyStore(){
try{
KeyStore ks=KeyStore.getInstance(KeyStore.getDefaultType());
ks.load(null,"".toCharArray());
FileOutputStream ksout=new FileOutputStream("myks.keystore");
char[] password = new char[] {'m','y','n','a','m','e'};
ks.store(ksout, password);
Arrays. fill(password, '\u0000' ) ;
}
catch(Exception e){
e.printStackTrace();
}
}
then i tried to store a generated key using an alias
public static void putEntriestoKS(){
try{
KeyStore ks=KeyStore.getInstance(KeyStore.getDefaultType());;
FileInputStream fin=new FileInputStream("myks.keystore");
char[] password = new char[] {'m','y','n','a','m','e'};
ks.load(fin,password);
FileOutputStream fout=new FileOutputStream("myks.keystore");
KeyGenerator kg=KeyGenerator.getInstance("AES");
SecretKey skey=kg.generateKey();
ks.setKeyEntry("mysecretkey", skey, password,null);
ks.store(fout,password);
Arrays.fill(password,'\u0000');
}
catch(Exception e){
e.printStackTrace();
}
}
when i run this i am getting a java.security.KeyStoreException: Cannot
store non-PrivateKeys
How then can i store SecretKey ?Do i have to use another provider?can
someone explain?
thanks
Jim
|
|
|