| executing data needs mprotect with PROT_EXEC |
|
 |
Index ‹ java-programmer
|
- Previous
- 2
- Problems in xml parsingHi,
I am using XMLTool.java to convert an xml file into an xml document
and
I am parsing the xml file using Nodelist and Nodes.
NodeList ls = getElementsByTagName("xxx").
Its working fine when I am running my application in windows.
But when I am running the same application in unix, I am getting
exceptions while parsing. Its giving null value and I cannot proceed
further.
Can anybody pls suggest where I am doing wrong?
I appreciate your help.
Regards,
Hari.
- 3
- grant execute file permission to a JSP? I'm trying to run an external command from a JSP and instead get
the exception:
java.security.AccessControlException: access denied (java.io.FilePermission /usr/bin/killall execute)
which seems clear enough. (The code runs and works from within a
console application.)
The OS is Linux and the application server is the one that
installs with the J2EE sdk from Sun. It is installed within my
home directory and runs under my user ID exposing deployed JSPs
at http://localhost:8080/
I've added the following code to both my ~/.java.policy file and
the ${java.home}/jdk/jre/lib/security/java.policy file:
grant codeBase "http://localhost:8080/-" {
permission java.io.FilePermission "/usr/bin/killall", "execute";
permission java.security.AllPermission;
};
Neither of the entries in either of the files makes any
difference. The only change I've made that has any affect at all
is to change the command from 'killall ...' to '/usr/bin/killall
...' which changed the file reference in the exception from "<<ALL
FILES>>" to "/usr/bin/killall".
Each time I made a change in the policy files, I restarted the
application server to make sure it was using the new file contents.
I'm clearly overlooking something or have something wrong. Any
suggestions on how to resolve this would be most welcomed!
thanks,
hank
- 7
- 13
- is it possible to use a backslash as a StringTokenizer delimiter?I am trying to tokenize a file path to compare it to another.
i.e tokenize: ways\gov\marketing.fls
to compare each directory seperately.
Is it possible to use the "\" (backslash) character as a StringTokenizer
delimiter, and if so how?
if not, any ideas on how to seperate this string?
Any help greatly appreciated
Thanks
Greenz
- 13
- Refinement of a Java prog called by PHPAfter listening to everybody's replies, I rephrase my problems as follows:
I modify my program from my client:
Class.forName("com.mysql.jdbc.Driver");
con = DriverManager.getConnection ( "jdbc:mysql://127.0.0.1/" +
dbstr, "root","");
...
after a series of search in the db "dbstr",
I want to return result from the search obtained by this Java program by
simply using System.out.printIn because I tried a C program and printf
simply works.
In order to make sure the java program can be called by PHP successfully, i
place it under the php directory instead of calling
system(java_prog_absolute_path/the_java_prog);
And the error returns from the java "slave" prog to the "master" php prog
is:
the error is:
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver at
java.net.URLClassLoader$1.run(URLClassLoader.java:200) at
java.security.AccessController.doPrivileged(Native Method) at
java.net.URLClassLoader.findClass(URLClassLoader.java:188) at
java.lang.ClassLoader.loadClass(ClassLoader.java:306) at
sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276) at
java.lang.ClassLoader.loadClass(ClassLoader.java:251) at
java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319) at
java.lang.Class.forName0(Native Method) at
java.lang.Class.forName(Class.java:169) at
SearchDatabase4.(SearchDatabase4.java:74) at
SearchDatabase4.main(SearchDatabase4.java:344)
And the file SearchDatabase4.java is:
74: Class.forName("com.mysql.jdbc.Driver");
344: new SearchDatabase4(args[0], Double.parseDouble(args[1]),
- 13
- log4j with OpenJMS
Anybody got sample code for sending log4j messages specifically to OpenJMS?
In particular I'd like to do it all programmatically, since I'm working with a fairly complex pre-existing build system and would rather not start introducing too many new properties files. I have a log4j.properties file, but I'm trying to avoid having to create a jndi.properties file.
I stuck this code from OpenJMS in my Logging utility (which wraps log4j):
Hashtable properties = new Hashtable();
properties.put(Context.INITIAL_CONTEXT_FACTORY,
"org.exolab.jms.jndi.InitialContextFactory");
properties.put(Context.PROVIDER_URL, "rmi://localhost:1099/");
Context context = new InitialContext(properties);
and log4j.properties has a simple:
log4j.myLogger=DEBUG, JMS1
log4j.appender.JMS1=org.apache.log4j.net.JMSAppender
log4j.appender.JMS1.TopicBindingName=testtopic
log4j.appender.JMS1.TopicConnectionFactoryBindingName=JmsTopicConnectionFactory
I keep getting the error "javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial" which leads me to believe that my block of code is not storing the InitialContext in a way so that log4j can get at it.
Thanks!
- 13
- WSIF and format:typemapping questionsHi to all of you,
I have to use wsif to call java, ejb and jms bindings. I wonna use
<format:typeMapping> extension to convert from xml to my custom Java
object. But somehow I cann not. Samples in WSIF zip are not enough to
solve my problems. Could someone give good tutorial or share his/her
experiense.
10x jajoo :)
- 14
- Bug#348398: Make her horny for youThe real trophy for her is what lies in your pants.
http://www.Steiplas.com/
Please don't forget this
--
To UNSUBSCRIBE, email to email***@***.com
with a subject of "unsubscribe". Trouble? Contact email***@***.com
- 14
- Code generation aplicationOn Mon, 11 Aug 2003 21:55:14 +0100, Alexandre Cotta Godinho wrote:
> Hello there !
>
> I need some help in increasing productivity. Do anyone knows about a
> code generation tool, as customizable as possible allowing to generate
> from UML dynamic diagrams as well. There is a nicely referenced product
> of name Codagen Architect (www.codagen.com), but it runs on Windows only.
>
> Thank you in advance
>
> Alexandre Cotta Godinho
TogetherJ or Rational Rose.
Both are -1 imo.
-c
- 14
- How can I do a barebones version of a source file?I need to create a barebones version of my Java source files.
What I mean when I say "barebones" is this: I have, for example, this class:
----8<--------8<--------8<--------8<--------8<--------8<--------8<----
package cl.cl.cl;
import cl.lc.*;
import java.util.*;
public class demo {
public String salute="Hello, World!";
private String somethingElse="";
public void SayHello() {
System.out.println(":::"+salute+":::");
// ... a lot of code ...
}
public int RealAge(Person p) {
// ... a lot of code ...
return theStuffIJustCalculated;
}
public Person[] Friends(Person p) {
// ... a lot of code ...
return theArray[];
}
}
----8<--------8<--------8<--------8<--------8<--------8<--------8<----
The barebones version would be:
----8<--------8<--------8<--------8<--------8<--------8<--------8<----
package cl.cl.cl;
import cl.lc.*;
import java.util.*;
public class demo {
public String salute="Hello, World!";
public void SayHello() { }
public int RealAge(Person p) { return 0; }
public Person[] Friends(Person p) { return null; }
}
----8<--------8<--------8<--------8<--------8<--------8<--------8<----
It would keep all the public/protected (not the private) attributes, methods,
etcetera, but only the declarations and no code inside the methods. The methods
that return something return a zero or a null value.
My intention is to be able to compile the entire set of source files, even if
there isn't any "meat" in them.
I wrote a Perl script, using pattern matching, but it's pretty crude and won't
handle properly stuff like more than one modifier for an attribute or a method,
or inner classes.
I'm wondering if this has been solved before. Do you know about a tool that does
what I'm trying to do?
Thanks in advance.
--
Miguel Farah
email***@***.com
- 15
- rapid development web interface to a databaseI am looking for the easiest web interface to a database. By easiest,
I mean most rapid development. Because the requirements are so simple
and standard, I'm hoping that something can take care of the grunt
work. Easy maintenance, possibly by non-programmers (or at least
"junior" programmers) would also be nice.
I'm open to Perl, PHP, Java in that order (best solution wins, equal
solutions go with the preferred language). I'm also open to anything
that doesn't require code to be written to get the job done, as long
as there's some way to extend it if I get stuck.
The design is simple and is an age-old story:
I have a database with about 15 tables. 5 contain data with the same
primary key, 2 have their own primary key but still a 1-to-1 mapping
to the "main" primary key, and 8 are master lists that the other
tables reference (site id, customer id, that sort of thing). I need
the following screens:
simple search based on a couple fields
advanced search based on most available fields
search results simple display, showing a reasonable set of fields
search results advanced display, showing large or configurable set of
fields
simple display, showing most commonly desired fields
advanced display, showing all data
add new record simple, requesting most commonly entered fields
add new record advanced, allowing all fields to be manipulated
edit existing record simple
edit existing record advanced
editing for each of the 'master' tables
All edit/add screens need pulldowns for master lists allowing one to
be selected, search screens need pulldowns allowing multiple to be
selected. The user should not be burdened by the underlying layout of
thed tabase.
I want something to do most of the grunt work of:
all the CGI stuff, of course
authentication and maintaining the session
building the forms. ugly is ok as long as it's usable. optional
templating would be nice.
working with the database
After everything is done modifying the interface to accomidate a new
table or new column in an existing table should be trivial.
I appreciate any advice about the most efficient way to develop such
systems.
- 15
- Tomcat4 RMI class loading bermuda triangleHi every body,
I'm trying to fix this problem for one week and i'm turning crazy
right now.
I have this servlet working perfectly, finding every package i put in
/var/tomcat4/shared/lib except that it doesn't find my RMIServer class
for casting
i get a
[java.lang.ClassNotFoundException] - myRMIServerClass
org.apache.catalina.loader.StandardClassLoader.loadClass(Unknown
Source)
org.apache.catalina.loader.StandardClassLoader.loadClass(Unknown
Source)
java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)
java.lang.Class.forName0(Native Method)
java.lang.Class.forName(Class.java:141)
all classes are in the jar with the stub and skeleton (i tried to put
classes in WEB_INF/classes of my servlet but same problem... so i
guess this is not the real problem)
I have set in catalina policy file a:
grant {
permission java.security.AllPermission;
};
to be sure there's no problem of security. i changed the
init.d/tomcat4 script to add -security to the starting line to be sure
that it is started the right way
i used to try the same code with tomcat 3 and i changed to tomcat 4
because of a rmi jni problem reported on mailing lists (i spent so
much time on tomcat4 that i can't remember what was the previous one)
but i can't even get that far with tomcat4
my version is a rpm 4.2.1 for Red Hat
does someone understand what's going on
- 15
- Hi iam bavaniHi iam bavani
life is the first gift
love is thesecond
understanding is the third
****************************************
htt:"my profile 22 blogs pot.com
**********************************************
username:bavanikumar22
***********************************************
- 15
- Failed to load or instantiate TagExtraInfo classI am using struts-1.3.8 tiles together with Spring, now I wanted to
implement my own custom tag. Following a book example, I wrote a
TagHandler that extends "SimpleTagSupport". Eclipse told me I needed
to import the jsp-api.2.0.jar from tomcat, so I did.
However, this always results in the error:
org.apache.jasper.JasperException: /WEB-INF/jsp/myjsp.jsp(1,1) Unable
to read TLD "META-INF/tld/struts-tiles.tld" from JAR file
"file:myFileLocation": org.apache.jasper.JasperException: Failed to
load or instantiate TagExtraInfo class:
org.apache.struts.tiles.taglib.UseAttributeTei
I did some research on the web, there it's said not to include the jsp-
api.2.0.jar (but not why not to), and yes, this solves the problem -
but how can I implement my Tag handler without using this jar file?
Eclipse doesn't find the required classes otherwise...
Thanks in advance,
Christine
- 16
- struts: Multipage formHi,
I'm collection data across several pages using one Form per page. The scope of
each form is set to session. Let's say I have form1, form2 and form3 and the
corresponding action classes. In the jsp corresponding to form3 I can access
form1 using form1 as bean name.
But how can I access form1 from the Action class corresponding to form3?
Hope that was not to confusing.
Thanks in advance,
phi
|
| Author |
Message |
Arne Juul

|
Posted: 2006-2-17 5:40:00 |
Top |
java-programmer, executing data needs mprotect with PROT_EXEC
This is a multi-part message in MIME format.
I've been trying to run some FreeBSD4 packages
inside a jail on a FreeBSD6 / amd64 box; and I've
hit a problem with ports/jdk.
A couple of places the VM uses an array of
integers, puts code in it, and executes it.
This doesn't work on machines where the CPU
honors the PROT_EXEC settings; this can be
different on different machines (depending on
BIOS settings probably).
The right fix is to call mprotect() from jdk to allow
execution of the memory in question, something like this:
--- ../../hotspot/src/os_cpu/bsd_i486/vm/os_bsd_i486.cpp Tue Feb
14 21:12:46 2006
+++ ../../hotspot/src/os_cpu/bsd_i486/vm/os_bsd_i486.cpp Wed Feb
15 16:30:49 2006
@@ -561,6 +562,9 @@
}
#else
static void (*fixcw)(void) = CAST_TO_FN_PTR(void (*)(void),
code_template);
+
+ ::mprotect((void *)code_template, sizeof(code_template),
+ PROT_EXEC | PROT_READ | PROT_WRITE);
#endif
fixcw();
--- ../../hotspot/src/cpu/i486/vm/vm_version_i486.cpp Thu Sep 11
03:40:14 2003
+++ ../../hotspot/src/cpu/i486/vm/vm_version_i486.cpp Tue Feb 14
23:34:40 2006
@@ -9,6 +9,8 @@
# include "incls/_precompiled.incl"
# include "incls/_vm_version_i486.cpp.incl"
+#include <sys/types.h>
+#include <sys/mman.h>
int VM_Version::_cpu;
int VM_Version::_cpuFeatures;
@@ -145,6 +147,10 @@
ResourceMark rm;
// Making this stub must be FIRST use of assembler
CodeBuffer* c = new CodeBuffer(address(stubCode), sizeof(stubCode));
+
+ ::mprotect((void *)stubCode, sizeof(stubCode),
+ PROT_EXEC | PROT_READ | PROT_WRITE);
+
VM_Version_StubGenerator g(c);
getPsrInfo_stub = CAST_TO_FN_PTR(_getPsrInfo_stub_t,
g.generate_getPsrInfo());
patches also attached in case the mail client mangles them :-)
- Arne H. J.
|
| |
|
| |
 |
Arne.Juul

|
Posted: 2006-2-17 5:54:00 |
Top |
java-programmer >> executing data needs mprotect with PROT_EXEC
This is a multi-part message in MIME format.
--------------070902020207040407010707
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
I've been trying to run some FreeBSD4 packages
inside a jail on a FreeBSD6 / amd64 box; and I've
hit a problem with ports/jdk.
A couple of places the VM uses an array of
integers, puts code in it, and executes it.
This doesn't work on machines where the CPU
honors the PROT_EXEC settings; this can be
different on different machines (depending on
BIOS settings probably).
The right fix is to call mprotect() from jdk to allow
execution of the memory in question, something like this:
--- ../../hotspot/src/os_cpu/bsd_i486/vm/os_bsd_i486.cpp Tue Feb
14 21:12:46 2006
+++ ../../hotspot/src/os_cpu/bsd_i486/vm/os_bsd_i486.cpp Wed Feb
15 16:30:49 2006
@@ -561,6 +562,9 @@
}
#else
static void (*fixcw)(void) = CAST_TO_FN_PTR(void (*)(void),
code_template);
+
+ ::mprotect((void *)code_template, sizeof(code_template),
+ PROT_EXEC | PROT_READ | PROT_WRITE);
#endif
fixcw();
--- ../../hotspot/src/cpu/i486/vm/vm_version_i486.cpp Thu Sep 11
03:40:14 2003
+++ ../../hotspot/src/cpu/i486/vm/vm_version_i486.cpp Tue Feb 14
23:34:40 2006
@@ -9,6 +9,8 @@
# include "incls/_precompiled.incl"
# include "incls/_vm_version_i486.cpp.incl"
+#include <sys/types.h>
+#include <sys/mman.h>
int VM_Version::_cpu;
int VM_Version::_cpuFeatures;
@@ -145,6 +147,10 @@
ResourceMark rm;
// Making this stub must be FIRST use of assembler
CodeBuffer* c = new CodeBuffer(address(stubCode), sizeof(stubCode));
+
+ ::mprotect((void *)stubCode, sizeof(stubCode),
+ PROT_EXEC | PROT_READ | PROT_WRITE);
+
VM_Version_StubGenerator g(c);
getPsrInfo_stub = CAST_TO_FN_PTR(_getPsrInfo_stub_t,
g.generate_getPsrInfo());
patches also attached in case the mail client mangles them :-)
- Arne H. J.
--------------070902020207040407010707
Content-Type: text/plain;
name="patch-os_bsd_i486.cpp"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="patch-os_bsd_i486.cpp"
--- ../../hotspot/src/os_cpu/bsd_i486/vm/os_bsd_i486.cpp Tue Feb 14 21:12:46 2006
+++ ../../hotspot/src/os_cpu/bsd_i486/vm/os_bsd_i486.cpp Wed Feb 15 16:30:49 2006
@@ -561,6 +562,9 @@
}
#else
static void (*fixcw)(void) = CAST_TO_FN_PTR(void (*)(void), code_template);
+
+ ::mprotect((void *)code_template, sizeof(code_template),
+ PROT_EXEC | PROT_READ | PROT_WRITE);
#endif
fixcw();
--------------070902020207040407010707
Content-Type: text/plain;
name="patch-vm_version_i486.cpp"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="patch-vm_version_i486.cpp"
--- ../../hotspot/src/cpu/i486/vm/vm_version_i486.cpp Thu Sep 11 03:40:14 2003
+++ ../../hotspot/src/cpu/i486/vm/vm_version_i486.cpp Tue Feb 14 23:34:40 2006
@@ -9,6 +9,8 @@
# include "incls/_precompiled.incl"
# include "incls/_vm_version_i486.cpp.incl"
+#include <sys/types.h>
+#include <sys/mman.h>
int VM_Version::_cpu;
int VM_Version::_cpuFeatures;
@@ -145,6 +147,10 @@
ResourceMark rm;
// Making this stub must be FIRST use of assembler
CodeBuffer* c = new CodeBuffer(address(stubCode), sizeof(stubCode));
+
+ ::mprotect((void *)stubCode, sizeof(stubCode),
+ PROT_EXEC | PROT_READ | PROT_WRITE);
+
VM_Version_StubGenerator g(c);
getPsrInfo_stub = CAST_TO_FN_PTR(_getPsrInfo_stub_t, g.generate_getPsrInfo());
--------------070902020207040407010707
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
_______________________________________________
email***@***.com mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-java
To unsubscribe, send any mail to "email***@***.com"
--------------070902020207040407010707--
|
| |
|
| |
 |
| |
 |
Index ‹ java-programmer |
- Next
- 1
- repeating program codeI've created a program that calculates real estate commission. The person
inputs the sale amount and then enters a letter which represents a certain
commission rate. It then calculates the commission and displays it. After
the commission amount is displayed i want it to prompt the user for
another transaction. When there are no more transactions i want the
program to display the total amount of the properties entered, and the
total amount of the commissions calcualted. I'm not too sure what to do.
Should i use a while loop? Here is what i have done so far.
// RealEstateCommission.java: Calculates real estate commissions
import javax.swing.JOptionPane;
public class Calculator {
/** Main method */
public static void main(String[] args) {
double salePrice;
double commissionRate = 0;
// Enter sale price
String salePriceString = JOptionPane.showInputDialog (null,
"Enter sale price",
"Calculator Input", JOptionPane.QUESTION_MESSAGE);
salePrice = Double.parseDouble(salePriceString);
// Enter property code (residential, multidwelling or commercial)
String propertyTypeString = JOptionPane.showInputDialog (null,
"Enter property code (residential (R), multidwelling (M) or
commercial(C))",
"Calculator Input", JOptionPane.QUESTION_MESSAGE);
if (propertyTypeString.equals ("R"))
commissionRate = 0.070;
else if (propertyTypeString.equals ("M"))
commissionRate = 0.060;
else if (propertyTypeString.equals ("C"))
commissionRate = 0.035;
// Calculate commission
double commission = salePrice * commissionRate;
// Format to keep two digits after the decimal point
commission = (int)(commission * 100) / 100.0;
// Show results
JOptionPane.showMessageDialog(null,
"the commission is" + commission,
"Cakculator Output",
JOptionPane.INFORMATION_MESSAGE);
String transactionString = JOptionPane.showInputDialog (null,
"Would you like to do another transaction (YES or No)",
"Calculator Input", JOptionPane.QUESTION_MESSAGE);
while (transactionString.equals ("YES"))
System.exit(0);
}
}
- 2
- IP-HOSTNAME Conversion ProblemHi,
I found many utilities in the web or rather the internet to resolve ip
address and host names , i took this example
host name : mp3.box.sk whose IP was resolved to be 69.31.81.51
now i took the same ip and tried to resolve the host name, for my
surprise i found that to be
colo-69-31-81-51.pilosoft.com which is not mp3.box.sk for sure, can
anyone explain as to why this problem is caused?
- 3
- Overheads involved in repeated acces to a database using JDBCI have an application that inserts words and their associated values
into a hashtable. If the word already exists in the hashtable, the
value associated with the word is increased in the hashtable. When the
hashtable is complete, I write its contents into a simple, two-column
table in a singer-user database using jdbc.I'm using MS Access at the
moment because my database doesn't need to support multiple -users or
very complex queries.
-Would I be better to take the hashtable out of the equation all
together? (i.e. read, write and update the values in the database as I
go along).
-Do you know if there is much overhead involved in contacting a
database in this way, as I would need to do it about 4,000 times?
I'm not sure how jdbc works.
-Can you alter the result set repeatedly and do a mass write to the
database at the end?
-Would another type of database suit my needs better?
Thanks in advance
~M
- 4
- Dangerous code up for peer reviewHi,
looking for some advice,
I have a database for addresses coded in java.
to print the addresses, a jframe is popped up that holds various report
layouts.
the user chooses a layout then this launches Jasper reports.
basically when the user presses the print button is the current screen is
hidden.
then a report layout screen is popped up, ( this cannot be a modal, as it
would sit on top of any screen generated by jreports)
the problem was , as the report layout screen was not a modal , the code was
returning directly back to the "mother screen" ,and un-hiding it.
to get round this problem I have implemented a couple of linked lists, where
the mother screens sets up a separate thread and then calls the child
screens to get their status.
here is a small section of the jasper report compiler
private void CancelButton_actionPerformed(ActionEvent e) {
sendStatus(CMD_SIGNAL_GOOD_EXIT); //send exit to calling routine
this.setVisible(false);
}
private void this_windowClosed(WindowEvent e) {
sendStatus(CMD_SIGNAL_GOOD_EXIT); //send exit to calling routine
//cancel the import
//here we need to exit the screen
this.dispose();
}
......
here is the signalling routine.
public void sendStatus(int currentStatus) {
String aa = String.valueOf(currentStatus);
addWork(aa);
}
public synchronized void addWork(Object o) {
queue.addLast(o);
notify();
}
//it is possible that the program could get hung here
//if the normal flow is interrupted
public synchronized int getWork() throws InterruptedException {
while (queue.isEmpty()) {
wait();
}
return Integer.parseInt((String) queue.removeFirst());
}
to stop the mother screen from being shown i have
r = new Runnable() {
public void run() {
try {
call the layoutscreen & jasper reports here
ReportWriter doReport = new ReportWriter(params,
my_vars.dbconn, errorlogger);
while (statusFlag != CMD_SIGNAL_GOOD_EXIT) {
statusFlag = doReport.getWork();
}
} catch (Exception ex) {
Error_stuff.handleError(ex, -1, -1);
} finally {
show();
repaint(); //refresh the screen
}
}
};
new Thread(r).start();
} catch (Exception ex) {
Error_stuff.handleError(ex, -1, -1);
}
i'm not really happy with the safety of the code, even though the exceptions
and all exits from the child screen are covered, and after testing the mother
screen is always shown again, even after an error.
- 5
- doModalHello.
How can I open a JFrame as a modal dialog box ?
Thanks :)
- 6
- Novell Tutorial: Building_A_Modern_Web_Application
http://developer.novell.com/wiki/index.php/Building_A_Modern_Web_Application
"As companies become more reliant on the Web, it is increasingly
important to deliver applications using the browsers that have the same
functionality as rich clients. Programming applications using HTML,
cascading style sheets (CSS), and Asynchronous JavaScript and XML (AJAX)
on the front end and using a Linux, Apache, MySQL, and PHP (LAMP) stack
on the back end helps to fill this gap."
"Everything presented in this article was done on a SUSE 10.0
workstation using the following versions of software:
* Apache 2.0.54-10.3
* MySQL 4.1.13-3
* PHP 4.4.0-6.8
* Firefox 1.5 "
--
The Texeme Construct
http://you-read-it-here-first.com
- 7
- Pre-Populate a Form that nested tagsI have a Struts action form which contains a bean. I am trying to
display a bean retrieved from the database in this form using the
nested tag. Can anyone help me? I continue to get an error message
see end for stack trace.
Struts config
<form-bean name="newBean" type="com.NewForm" />
.....
<action path="/new-action" type="com.NewAction"
name="newBean" scope="session">
<forward name="blah" path="/New.jsp"/>
</action>
Bean
public class Program implements Serializable {
private int prg_pk;
private String prg_prog_name = null;
private Set courses;
getters()/setters()
Form
public class NewForm extends ActionForm {
private Program program;
/**
* Returns the program.
* @return Program
*/
public Program getTheProgram() {
return program;
}
/**
* Sets the program.
* @param program The program to set
*/
public void setTheProgram(Program program) {
this.program = program;
}
public void reset(ActionMapping mapping, HttpServletRequest
request) {
HttpSession session = request.getSession();
setTheProgram((Program) session.getAttribute("PROGRAM"));
}
}
JSP
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/struts-nested.tld" prefix="nested" %>
<nested:form action="/new-action.do">
<nested:nest property="program" >
<nested:write property="prg_prog_name"/>
</nested:nest>
</nested:form>
Stack Trace
java.lang.NullPointerException
at java.util.Hashtable.get(Hashtable.java:315)
at org.apache.jasper.runtime.PageContextImpl.findAttribute(PageContextImpl.java:303)
at org.apache.struts.util.RequestUtils.lookup(RequestUtils.java:663)
at org.apache.struts.util.RequestUtils.lookup(RequestUtils.java:710)
at org.apache.struts.taglib.bean.WriteTag.doStartTag(WriteTag.java:290)
at org.apache.struts.taglib.nested.bean.NestedWriteTag.doStartTag(Unknown
Source)
at org.apache.jsp.New$jsp._jspService(New$jsp.java:114)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:201)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:381)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:473)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:243)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:190)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2347)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:468)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:1027)
at org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1125)
at java.lang.Thread.run(Thread.java:479)
- 8
- C++ to Java aplet, need help to understand.Hi,
I have a c++ application that uses Direct X to get images from my webcam.
Now I want to stream images from my application to the internet.
I just want to make sure I understand how a java applet would, (should?),
work.
When the user load the page where the java applet is located, the applet
makes a request to my machine for an image.
The applet then displays the image at a certain location in the page.
So a java applet does not really 'stream' videos, instead it makes a request
for an image every 'x' seconds.
All the applet needs is address and port where my application is located,
(and the name of the function that will return the frame).
Sadly I have no knowledge of Java, (well a little maybe).
Where could I find some code for an applet that would make a request to my
application.
How can a java applet make a request to a win 32 c++ application?
And what would the code look like in an html page?
Many thanks in advance for any help/code.
Simon
- 9
- simplifying use of properties"Stefan Schulz" <email***@***.com> wrote in message news:<opsg4x3eg6q1fd9p@localhost>...
> The change you describe is inherently incompatible, though.
Not if you change reflexive field access to match the hardcoded
equivalent.
> In fact, the
> VM you describe is fundamentally different and incompatible to the current
> JVM.
> What you argue for is effectively another language with
> wholely different concepts.
I don't think so.
> I'll not say that these concepts in themselves
> have no merit, but in the Java programming language, they are not
> appropriate, since they run against several other principles of the
> language's
> design.
Like what?
> >> > No merit? Properties are supported in many languages like Python,
> >> > Ruby, C# and (I think) VB.
> >>
> >> So what? They are in java too (see the public modifier for fields) ;)
> > Once you have a public field in Java, you can't later replace it with
> > accessor methods without breaking clients. But in Python, Ruby & C#,
> > you can. That is what I meant by "properties" as opposed to "fields"
> > or "instance variables".
>
> No, you can't. Think about reflexive invocation - Will work with a public
> method, will not work with a inaccessable field, and getter/setter pairs.
That's not a problem; I wasn't proposing changing the semantics of the
invokevirtual instruction for somebody to complain that the parallel
using reflection behaves differently from a hardcoded invocation. What
we do need to change is reflexive field access: it should invoke the
getters & setters when the field isn't found. But that's pretty
logical.
>
> >> It will however make it even more of a living hell to explain tonovices
> >> that a setter/getter pair need not be backed by one andonly one field
> >> of the arguemnt type.
> >
> > Getter/setter pairs that are not backed with fields are used all the
> > time in Java. I'm only proposing an easier syntax for their use.
> > Regarding the novices bit, OO theory says that when you call a method,
> > you should *not* be concerned with how it's implemented. I feel you
> > should not be telling novices that a getter/setter pair always has to
> > be backed with a field.
>
> This is what i said. Most assume it has to be backed by a field, and if
> you use field access syntax, you reinforce that notion.
Maybe, but I still think it's straightforward for novices to
understand that what looks like a field access may be an invocation,
once you explain it to them. There are tougher concepts novices must
understand.
- 10
- Announcement: PerfectJPattern first release 1.0.0 available ...hi,
After long working hours have been able to finally put together a first
release of PerfectJPattern. The aim of PerfectJPattern is to build a
library of componentized (reusable and context-free) Design Patterns
in Java.
Please visit the home page under: http://perfectjpattern.sourceforge.net
Feedback most welcome!
Best regards,
Giovanni
PS: I still have plenty to work on the documentation again any feedback
with corrections/suggestions will be most welcome.
- 11
- Confused about referencing info stored in a JFrame
I've tried to develop several JFrame programs in the past and it
always drives me crazy because I can't figure out how to set Classes
I've developed, which aren't Components, but are critical to storing
information necessary for the program to operate, so that they can be
seen by components inside the frame. I'm not very knowledgable about
the structure and coding of Swing/AWT programs, but I understand the
princepals of passing data between methods and classes, and it is very
frustrating to me that I cannot find an easy way (or even a working
way at this point) to reference the info with my program the way I
need to.
To illustrate my question with a real example, I'm trying to write a
program which allows employees at my job to easily receive products
from deliveries by scanning the barcode on the product or putting in
the supplier code on the invoice.
The program needs to be able to extract product info from the database
(to match the scanned barcode and to give the receiver visual
verification that the info in the system is correct), and it needs to
be able to match the product with the vendor, and thus the vendor
codes, which go with the invoice.
I've connected my first draft/test program to the database using a
class I call dbInfo. This class stores the connection information
specific to our database, and also acts as a container/manager for
other classes which populate arraylists such as VendorList, BrandList,
and lists for any other info which is tied to a primary key in the
database and might change during the use of the program (this way in
the info in the form can be refreshed by simply using one dbInfo
method).
My dbInfo class populates all its info into the appropriate lists
correctly. I cannot, however, get my components to see this info.
For example, I have a VendorBox, which is a JComboBox that selects the
vendor for the invoice.
My original vendorBox grabbed its vendor information directly from the
database by storing its own JDBC info and generating the SQL statement
itself. This worked fine, but is not very modular, I had to add code
to every other component that dealt with this info which would to
reference the specific VendorBox on that JFrame form. If I could get
the components to see the dbInfo for the form, I could just store the
reference to VendorBox as dbInfo.invoiceVendor and any other component
could have easy access to it by simply knowing where dbInfo was.
Long explanations can be hard to read, so here's a basic diagram
------------------------------
JFrame
|
}Components
| }VendorBox ( a ComboBox which selects the
| vendor to receive from )
|
}dbInfo (not a component)
}VendorList
------------------------------
My Question: How to I get VendorBox to see VendorList (or dbInfo for
that matter)?
------------------------------
*Note: I'm using Netbeans 5.5, which doesn't allow me to edit the
component initialisation proccess inline. I think I might be able to
do this using the properties window, but I haven't had any luck
getting this to work*
What I've tried:
Just putting it in based on its name and location:
1) A direct reference - using a setdbInfo() method, which sets the
dbInfo equal to JFrameName.dbInfoVariableName. Netbeans gives me a
variable (or symbol or something of the like) not found.
2) The Netbeans property window - because I have setdbInfo() and
getdbInfo() fields in my VendorBox class, Netbeans shows dbInfo in the
property window. Trying to edit this property gives me a form which
among other things says 'form connection mode' and has options like
'from property' and 'from method'. None of the options have any
options to select within them, which I think is because i need to do
something to set up the form connections, but I'm not sure and my own
personal searches have not presented me with useful information.
At this point I thought I'd try to make a finddbInfo class, which
would just find the dbInfo class by crawling its way out
3) Introspection - When I read the description of this I sighed
relief, I thought it would show me the class that my VendorBox was
inside, but as far as I can tell it only shows you the class
inheritance information. I tried all the getxxx() commands netbeans
offered for code completion, but all I got back was info from the
classes my vendorBox was built on or null.
4) VendorBox.getParent() - combined with introspection, I used this to
progress a Class from displaying info about my vendorBox to info about
its containing panels, when I progressed to the outmost panel,
however, instead of getting the JFrame info on the next entry, I got
null.
At this point I cried, cut myself, and poured the rest of my drink out
for my dead homies.
Please help me, I enjoy using Java because I can work with it quickly,
but I feel like screaming sometimes because I can't pass a simple
piece of info to a component. I've learned so much more than I needed
to and wasted so much valuable time trying to do this and I know in my
heart that there is an easy answer that will make me feel
simultaneously stupid and relieved. I need that feeling like you
wouldn't believe, and I'm sure there our other amateur programers out
there who could benefit greatly by understanding why my methods don't
work.
On that note, if you could even explain why solutions like 1) or 4)
don't work, I think a lot of people could benefit from that info.
- 12
- Latte Diablo JRE 1.3.1 binary package on FreeBSD4.7Hi All,
I was wondering if anyone else at Imeme has had any success with getting
JDK /usr/ports/java/jdk13 working on their jail.
Also if anyone on the freebsd-java list has any experience getting jdk13
working on FreeBSD 4.7 I would much appreciate any help.
The build command I am running in /usr/ports/java/jdk13 is
make build FORCE_PKG_REGISTER=1 WITHOUT_X11=1
I am not sure if I need (or if it does anything) the WITHOUT_X11=1 but I
know that we aren't running X11 and have used that on ports before so
thought I would try it.
make goes off and does a lot of stuff and ends with the following:
---------------------------------
gmake[3]: *** No rule to make target
`../../../build/bsd-i386/classes/META-INF/services/javax.sound.sampled.spi.FormatConversionProvider',
needed by `copy-files'. Stop.
gmake[3]: Leaving directory
`/usr/ports/java/jdk13/work/j2sdk1.3.1/make/javax/sound'
gmake[2]: *** [optimized] Error 2
gmake[2]: Leaving directory
`/usr/ports/java/jdk13/work/j2sdk1.3.1/make/javax/sound'
gmake[1]: *** [all] Error 1
gmake[1]: Leaving directory
`/usr/ports/java/jdk13/work/j2sdk1.3.1/make/javax'
gmake: *** [all] Error 1
*** Error code 2
Stop in /usr/ports/java/jdk13.
--------------------------------
I tried a make clean and then the same command just in case and same thing.
This looks like something to do with sound. Seeing as we don't actually
need sound to work I wonder if there is a way to skip that. Anyone know
where I could look?
Cheers,
Pete
--
Peter Simmons
Senior Consultant BCMPweb Limited
M:+64 21 676 909 F:+64 9 374 4250
email***@***.com http://www.bcmpweb.com
_______________________________________________
email***@***.com mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-java
To unsubscribe, send any mail to "email***@***.com"
- 13
- Swing Applet, JDBC and MySQL Connector ConfusionI believe your applet must be run from a signed jar, and the MySQL database
must also be resident on the same server as the applet. I'm not 100% sure of
this in your case....but I am 99% sure. -Ike
- 14
- improve J2EE performanceI have installed on my computer Sun J2EE server to use IMQ.
Normally after boot I digit :
./[path]/bin/asadmin start-domain domain1
but the performance aren't good , because I use an application with (more
or less) some hundreds msg/minute.
How Can I improve this server's performance ?
I can start this server on another runlevel or I can allocate to him more
resources ?
--
Ciao Flex
________________________________________________
Chi sa ascoltare non solo e' simpatico a tutti ,
ma prima o poi finisce con l'imparare qualcosa
- 15
|
|
|