| JSF, automatic execution of backing bean action |
|
 |
Index ‹ java-programmer
|
- Previous
- 4
- wireless codeHi,
I'm planning to do my own simulator of TCP snoop protocol in wlan (in java
programming language). So if anyone have code related to this work please
e-mail to me. Or any source related to wlan.
Thanks!
- 5
- The decline of the Applet vs Flash 2000-2004I graphed the level of technology penetration by Applets versus Flash
from 2000 to 2004, using May as the reference month. In this case, the
data points were collected by SecuritySpace.com through surveys of a
few hundred thousand sites - determining what percentage of each site
contained Applets, and which contained Flash. As expected, Flash usage
has risen steadily since 2001, while the use of Applets has slowly
fallen by nearly 50% since the same year.
http://www.blueboard.com/phone/applet_vs_flash.gif
Although at first glance, this might seem like an altogether bad news
for Java Applets, in one sense it yields a lode of good news. I once
came in charge of a site that was unbelievably enough, using Java
applets as the navigation buttons - not just one applet, but a series
of small applets running down the side of the web site! Needless to
say, I tore those things down and replaced them with images as soon as
I could.
This points to the fact that it is so very easy to misuse Applets in
designing a website, a problem that resulted in clunky, slow-loading
(not to mention, browser-killing) sites a while back, and created a
backlash against Java in general that continues to this day. If
achieving high penetration results in such gross misuse and abuse,
then perhaps it would be best to re-evaluate the place of Java applets
in web programming - quality rather than quantity, so to speak.
Let Flash have its day as the premier method of creating small
animations, banners and demos - while Java Applets finally mature as
the basis of higher-end browser-based applications - things such as
the streaming portfolio applications of stock traders, interactive 3d
applications such as this
(http://grs.lpl.arizona.edu/~guym/ody_3d.html), mapping applications
like those of Map24 (http://www.map24.com/) , and others (e.g.
http://www.altio.com/demo.htm).
There are literally tons of really good applets out there, so maybe
someone should compile an advocacy page for these (and I don't mean
Swing Sightings).
- 7
- Newbie functions questionHi,
I'm new to this JSP stuff, but familair with ASP and Javascript so I hope
that helps me. (I did post this in the java NG but that seems quite dead)
I am trying to do a simple function that simply writes the value of Test to
the screen and have no idea to do this (I need to pass a value into a
function that does something) but I am getting errors.
Something similar to :
<%
function MyFunc(ValueIn)
{
%>
<%=ValueIn%>
<%
}
MyFunc("My thing to print to screen");
%>
but this doesn't seem to work.
Any info on how to achieve this would be greatfully received.
Many thanks
Stu
- 7
- Condition outside loop or separate loop for different condition?Should I adopt the first or the second way?
The first makes it faster. The second makes the code shorter.
The size to compare is not in the millions so which should i go with?
First Way:
private Comparator createXComparator() {
return new Comparator() {
public int compare(Object object1, Object object2) {
int value = 0;
A a1 = (A) object1;
A a2 = (A) object2;
if (a1.getX() < a2.getX()) {
value = -1;
} else {
value = 1;
}
return value;
}
};
}
private Comparator createYComparator() {
return new Comparator() {
public int compare(Object object1, Object object2) {
int value = 0;
A a1 = (A) object1;
A a2 = (A) object2;
if (a1.getY() < a2.getY()) {
value = -1;
} else {
value = 1;
}
return value;
}
};
}
Second Way:
private Comparator createComparator() {
return new Comparator() {
public int compare(Object object1, Object object2) {
int value = 0;
A a1 = (A) object1;
A a2 = (A) object2;
if (...) {
if (a1.getX() < a2.getX()) {
value = -1;
} else {
value = 1;
}
} else {
if (a1.getY() < a2.getY()) {
value = -1;
} else {
value = 1;
}
}
return value;
}
};
}
- 7
- E-mail sending problem. Dear Experts,
I have an application, which is running at Windows platform and used to
send e-mails through the Microsoft Exchange server. Unfortunately this
server is configured to make a strong client authentication, so I have
to use a user ID and a password in my codes (see below). Without the
lines, marked by (*), I have the error message: "454 5.7.3 Client was
not authenticated".
Is it possible to avoid this authentication procedure, using a simple
fact: both application and e-mail server are running on different
computers, but under the Windows OS?
Regards,
Serguei.
Properties props = new Properties();
props.put("mail.smtp.host", "myhost");
props.put("mail.smtp.auth", "true"); <-- (*)
Session session = Session.getDefaultInstance(props, null);
Message msg = new MimeMessage(session);
msg.setFrom(new InternetAddress(fromAddress));
InternetAddress[] address = {new InternetAddress(toAddress)};
msg.setRecipients(Message.RecipientType.TO, address);
msg.setRecipient(Message.RecipientType.CC, new
InternetAddress(ccAddress));
msg.setSubject("JavaMail APIs Test");
msg.setSentDate(new Date());
msg.setText("msgText");
Transport transport = session.getTransport("smtp");
transport.connect(host, "userId", "password"); <-- (*)
transport.sendMessage(msg, msg.getAllRecipients());
transport.close();
- 8
- Using Eclipse for JSP developmentHello,
I am using eclipse as a tool to develop JSP files alongwith Tomcat
Sysdeo plug-in .
I have created a Tomcat project and imported a JSP project folder to
it.
When I open a JSP file, I am not getting much features of Eclipse to
work with it.
i.e. i was not able to format the code, the keywords are not being
highlighted in colour etc.
How to utilise Eclipse functionality/features for J2EE development?
Do i have to enable some features of Eclipse?
I searched in Eclipse help, Tomcat plug-in menus but unable to find
out.
Please help me.
-Sameer
- 9
- Visual Insight and JRE 1.4.1_02Hi,
I'm trying to run Visual Insight using JRE 1.4.1_02 and it gives me
following error:
Java(TM) Plug-in: Version 1.4.1_02
Using JRE version 1.4.1_02 Java HotSpot(TM) Client VM
----------------------------------------------------
java.lang.UnsatisfiedLinkError: no JNv2342 in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1403)
at java.lang.Runtime.loadLibrary0(Runtime.java:788)
at java.lang.System.loadLibrary(System.java:832)
at vdi.In3D.JIn3DApplet.<clinit>(JIn3DApplet.java:36)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:274)
at java.lang.Class.newInstance0(Class.java:306)
at java.lang.Class.newInstance(Class.java:259)
at sun.applet.AppletPanel.createApplet(AppletPanel.java:567)
at sun.plugin.AppletViewer.createApplet(AppletViewer.java:1778)
at sun.applet.AppletPanel.runLoader(AppletPanel.java:496)
at sun.applet.AppletPanel.run(AppletPanel.java:293)
at java.lang.Thread.run(Thread.java:536)
Though the same applet works fine if I install JRE 1.3. I tried
looking for the file JNv2342 on my system - but couldn't find it.
Does anybody has any idea what is there in this dll and why is it
missing in JRE 1.4(I'd expect 1.4 to be backward compatible)?
Thanks,
Anand
- 10
- setWidth(44= of a Container/ContentPane does not workI would like to set the width of a Container/ContentPane to 400 pixel.
But the following does NOT work:
How do I do it otherwise?
Container contentPane = getContentPane();
GridBagLayout gridbag = new GridBagLayout();
contentPane.setLayout(gridbag);
contentPane.setWidth(400); -->Compiler Err
Tom
- 10
- HashSet: add() during iteration?What happens when I add a new item to a HashSet during iteration? Will
the new item added eventually be included in the iteration, will it not
show up, or is it unpredictable?
I *want* it to be included, so if it isn't I'm going to have to use more
complicated logic, where each time through an iteration I build the next
HashSet to be iterated over, and I use a loop to iterate through each of
the HashSets until I get to an empty one. Much nastier, but I suspect
I'll have to -- please tell me that I'm wrong!
Thanks,
Bruce Feist
- 12
- DeepCopy problems with dissolved proxyHey!
I get myself construct me from data base entries an object structure.
And make one deepcopy from this object structure. So far so well.
The problem is in the copied object structure not all proxys are
dissolved.
That is, with accessed the dissolved objects, I get a big bang.
Do you know about a solution to dissolved the proxy before or during
the deepcopy?
My persistence framework is hibernate!
...
public abstract class HibernatePersistentDomainObject implements
HibernatePersistentDomain, Serializable{
...
public static Object deepCopy()
{
try{
ByteArrayOutputStream myBAOutputStream = new
ByteArrayOutputStream();
new ObjectOutputStream( myBAOutputStream ).writeObject( this
);
ByteArrayInputStream myByteArrayInputStream = new
ByteArrayInputStream( baos.toByteArray() );
return new ObjectInputStream(myByteArrayInputStream
).readObject();
}
catch(Exception e){
ServerLog.error("DeepCopy failed!");
return null;
}
}
}
......................
horst
- 16
- Threads in JMS listeners?Could someone please post a working example of using threads and JMS,
of either a queue or topic listener? I searched google a lot, and have
a book with vague examples - neither of which have got me very far.
Thanks,
iksrazal
- 16
- Question on efficient copy from one array to another, code includedHi people, the following code works but my question is is there a
(far) more efficient way of populating the array _byte from the array
bufferB. In the demo application below there I am only copying over 8
bytes, but in the real program I am copying 100's.
Thank you
Barry
package com.somewhere;
public class Class1
{
private static byte[] _byte=null;
public static void popByte(byte[] bufferB,int noOutOfTotalToCopy, int
start)
{
_byte=new byte[noOutOfTotalToCopy];
//is there a more efficient way of copying from bufferB to _byte?
int finish=start+noOutOfTotalToCopy;
for (int i=start;i<finish;i++)
_byte[i-start]=bufferB[i];
}
public static void main(String[] args)
{
byte[] test={1,3,2,56,23,3,6,23,5,4,2,5,76,6,4,2,17,19,32,32,34};
popByte(test,8,3);
}
}
- 16
- JWS 1.2Anybody got the Java Web Services 1.2 tutorial to work on Windows yet?
I installed the tutorial on C: and the JWSDP on d: so maybe that is a
problem?
Symptom: "ant install" does not copy the war file as it is supposed to
do.
Anybody have any idea about this? I think all ant is doing is calling
the TomCat manager?install... so maybe TomCat is mis-configured?
Fixed Symptoms: "ant build" says it works but does not create
.../build.
Fix: use fwd slashes and no c: in build.properties
Another question: JAXM is java-to-java SOAP message passing but is not
in JWS 1.2. JWS 1.2 has SAAJ which seems to do the same thing but
allow SOAP message passing to non-Java. Is this right?
Thanks!
TimJowers
P.s> ignore the Balachandra spam "Here is the best book on web
services
http://www.amazon.com/exec/obidos/ASIN/1558609008/india"
since that book was published in April and is pre-JWS 1.2.
The tutorial is well-written but apparently not well-tested.
- 16
- 16
|
| Author |
Message |
Micke

|
Posted: 2005-10-4 6:19:00 |
Top |
java-programmer, JSF, automatic execution of backing bean action
Hi,
I am new to JSF and can not quite figure out how to solve the following
problem.
I would like to be able to call JSF like a servlet, by having the
request parameters mapped to a managed bean in request scope. Then have
an action executed automatically which processes the request parameters
and returns control to an ordinary JSF page. It would be nice to have
the action prepare the data to be displayed, and then have a normal JSF
page display it.
Example of the URL style I am thinking of:
http://www.hello.com/tool/getJob.jsf?id=abracadabra&tool=toolname&sorting=col2
(This would only be a small part of a larger applicaton, otherwise I
would have used a servlet to do this.)
Is it at all possible and sane to use JSF in this way.
Other stategy:
Thank you, Mikael
|
| |
|
| |
 |
HGA03630

|
Posted: 2005-10-4 7:29:00 |
Top |
java-programmer >> JSF, automatic execution of backing bean action
I think your problem could be readily solved by a proper
navigation-rule
entry in your faces-config.xml.
> request parameters mapped to a managed bean
<h:textInput id="abracadabra" value="myBackingBean.foo" ..... />
|
| |
|
| |
 |
Micke

|
Posted: 2005-10-4 14:33:00 |
Top |
java-programmer >> JSF, automatic execution of backing bean action
Hi,
the thing is that I don't want the user to have to click on a link, but
have and action method on a backing bean be i invoked without the user
having to do anything. I also was thinking I could wire the request
parameters to the backing bean in the faces-config.xml file (when I set
up the managed bean).
Thanks, Mikael
|
| |
|
| |
 |
HGA03630

|
Posted: 2005-10-4 15:03:00 |
Top |
java-programmer >> JSF, automatic execution of backing bean action
Micke 銇儭銉冦偦銉笺偢:
> Hi,
> the thing is that I don't want the user to have to click on a link, but
> have and action method on a backing bean be i invoked without the user
> having to do anything. I also was thinking I could wire the request
> parameters to the backing bean in the faces-config.xml file (when I set
> up the managed bean).
>
> Thanks, Mikael
If the component is a <h:inputText />, you could use some attributes
including valueChangeListener, converter, validator and variety of
onXXXXXs. In some cases you could even use setter methods for bean
properties to do something. Wiring the request parameter to the backing
bean will also be done via simple EL expression on the JSF component.
|
| |
|
| |
 |
Micke

|
Posted: 2005-10-5 1:08:00 |
Top |
java-programmer >> JSF, automatic execution of backing bean action
Hi,
thanks for you replies, but I'm not sure they solve my problem.
I want the example URL to execute Java logic immediately without the
user having to press a link or button, just like when calling an
ordinary servlet (doPost() ). I don't think your proposals help me do
that, do they?
Cheers, Mikael
|
| |
|
| |
 |
Micke

|
Posted: 2005-10-6 2:58:00 |
Top |
java-programmer >> JSF, automatic execution of backing bean action
Some help please, anyone.
|
| |
|
| |
 |
| |
 |
Index ‹ java-programmer |
- Next
- 1
- need help with jar archivHi,
I need some help with my jar archive.
I need to read a file in my program. I do that with
FileReader.
To locate the file I use getClass().getResource("key/key.txt")
I used the above class.getResource so that teh programme locates the file
in the jar archive. But it doesn't work after getting packed in
jar, otherwise works perfectly alright.
I use the following command to make the jar:
jar cmf caesar/mainClass cipher.jar caesar/c*.class caesar/key/key.txt
Can somebody please help me with that.
I get a error-message as follows
file:\E:\myprogs\Security\cipher.jar!\caesar\key\key.txt ( The syntax for
the filename,
directory and data volume is wrong)
The relevant code lines:
URL fileUrl = getClass().getResource("key/key.txt");
// String filename = fileUrl.getFile();
System.out.println(fileUrl.getFile());
try {
System.out.println(fileUrl.getFile());
BufferedReader read =
new BufferedReader
(new FileReader(fileUrl.getFile()));
Regards,
Sunil
- 2
- trying to extend messageresources classhi..
i'm trying to create my own messageresources class and placed:
<init-param>
<param-name>application</param-name>
<param-value>coreservlets.Messages</param-value>
</init-param>
<init-param>
<param-name>factory</param-name>
<param-value>coreservlets.MessageFactory</param-value>
</init-param>
in the web.xml file of the context, but struts, ignores it and keeps
using it's own.
- 3
- Images from Jar Files? - How do YOU do it?
It occurs to me that this may be the best way to approach this situation:
If you have a stand-alone java application that runs from a JAR file,
and you have images contained in that JAR file that your application
loads... how do YOU do it?
I'm specifically interested in Jar Bundled applications for OSX, but any
code will do.
If anyone could provide sample code, it would be very much appreciated!
CT
- 4
- Multiline Textbox For Web pageHello,
I have been trying to get a textbox to work now for over a week, and
am starting to think there is not answer. I have a web application
that populates an htmlinputtextarea. The reason I chose it was
because it could display multiple lines. However, if the report gets
too wide for the textbox, the text starts to wrap. I have tried
override and white-space for CSS class, but the best I can get is one
long line (white-space: nowrap). For the setValue, I use \r\n for my
end of line. Example: txtBox.setValue("This is one line\r\nThis is
line two.");
Is there a better textbox than the htmlinputtextarea to display
multiple lines of text with a vertical and horizontal scrollbar? If
not anybody know what I am doing wrong?
Thanks for any help
Ryan
- 5
- Creating EJB Instance on server startupHi,
I programmed a stateless SessionBean that acts as a timer service
(implements TimeObject). Since this timer service should be available
after the server has started, I am looking for a way to realize this. I
thought about creating a pool, where at least one instance is residing
in so I configured in my jboss.xml:
<container-configuration extends="Standard Stateless SessionBean">
<container-name>Pooled Stateless SessionBean</container-name>
<instance-pool>org.jboss.ejb.plugins.StatelessSessionInstancePool</instance-pool>
<container-pool-conf>
<MinimumSize>1</MinimumSize>
<MaximumSize>1</MaximumSize>
<strictMaximumSize>1</strictMaximumSize>
</container-pool-conf>
</container-configuration>
But this doesn't bring the expected result. I realized, that the
ejbCreate method of my session bean is called as recently as I am
calling a custom method of my remote interface. So my container isn't
creating any bean instance at all at the startup. What can I do now ?
Thanx,
Phil.
- 6
- searching for encrypted fields in data columnsI am new to database programming and was curious how others solve the
problem of storing encrypted in data in db table columns and then
subsequently searching for these records.
The particular problem that I am facing is in dealing with (privacy)
critical information like credit-card #s and SSNs or business critical
information like sales opportunity size or revenue in the database. The
requirement is that this data be stored encrypted (and not in the
clear). Just limiting access to tables with this data isn't sufficient.
Does any database provide native facilities to store specific columns as
encrypted data ? The other option I have is to use something like RC4 to
encrypt the data before storing them in the database.
However, the subsequent problem is how do I search/sort on these columns
? Its not a big deal if I have a few hundred records; I could
potentially retrieve all the records, decrypt the specific fields and
then do in process searches/sorts. But what happens when I have (say) a
million records - I really don't want to suck in all that data and work
on it but instead use the native db search/sort capabilities.
Any suggestions and past experiences would be greatly appreciated.
much thanks,
~s
- 7
- pico, nano, micro and JavaFirst off, this is for a school assignment... I know some people get
squeamish about this sort of post, but I'm kind of up a creek.
Basically, as part of a semester-long project, we need to add another bean
to a program we've been working on, and integrate it with the rest of the
program. That part's not the issue.
Part of the specification for the bean states tnat the user must be able to
select (and optionally enter) values ranging from 100 picofarads up to 1
microfarad. That's 1 * 10^-10 up to 1 * 10^-6, and everything in between.
Now... For ease of use purposes, the input is supposed to involve something
like a combobox or a spinner or a slider, or something like that, with
clearly delineated default values, which the user can then customise.
So, for testing purposes, I have a combobox containing the numbers 1 to 10,
and a second combobox that allows you to select your unit (pF, nF, uF).
So... In an attempt to get this post over with... Does Java include a
quick and easy way of taking an entry like "250 nF" and converting it to
2.5*10^-7 for calculation purposes? I was thinking of putting the whole
thing into a switch based on the contents of the units box (or possibly a
bunch of if statements), but then there's the problem of a certain amount of
variation in the multipliers used depending on the actual number entered.
Does any of this make sense?
- 8
- JSP Code Review Tool or Syntax Analyzer?We use an automated Java source code review tool (Hammurpai) in our
company. It does the job. However, we write a substantial amout of JSP
code for web and voice applications. The Java code review tool says it
will also handle JSP, but you need to run it through Jasper first to
turn it in to *.java files. I've been searching all over, but can't
find what I need. I want to take a directory and sub-directories of
*.jsp files and run them through an automated tool that checks for
syntax, parameter naming conventions, closed attribute quotes, closing
tags, ample whitespace, quantity of comments, etc. I want it to show
the violations so the code can be fixed before being bundled and
deployed, only to find out later that it has a problem compiling
because of a missing closing quote. Does anything like this exist out
there?
- 9
- Need help in CLASSPATH/Packagehi everyone,
i am having a strange problem regarding package/classpath.
Very Sorry, Its a long post but please help.
I did like this:
I created MyMath.java file in C:\Java , the contents were:
package com.anbh.Maths;
public class MyMath {
public static int add(int x, int y) {
return x + y;
}
public static int sub(int x, int y) {
return x-y;
}
}
Created file UrMath.java again in C:\Java, contents were :
package com.anbh.Maths;
public class UrMath {
public String callMe() {
return "Inside CallMe()";
}
}
Created file TempClass again in C:\Java, Contents were
import com.anbh.Maths.*;
public class TempClass {
public static void main(String[] args) {
System.out.println(MyMath.add(-1, -1));
UrMath ob = new UrMath();
System.out.println(ob.callMe());
}
}
Then I compiled it like below: (My current directory was C:\Java)
javac -d . MyMath.java UrMath.java
This Complied successfully and created directories C:\Java\com\anbh\Maths.
Then I tried to compile TempClass.java like: (My current directory was C:\Java)
javac -classpath . TempClass.java
I got the error:
TempClass.java:6: cannot access MyMath
bad class file: .\MyMath.java
file does not contain class MyMath
Please remove or make sure it appears in the correct subdirectory of the classpath.
System.out.println(MyMath.add(-1, -1));
^
1 error
Now, when I changed the TempClass.java file's import statement as:-
import com.anbh.Maths.MyMath;
import com.anbh.Maths.UrMath;
i.e. I named every class individually, EVERYTHING WORKED FINE.
Why import com.anbh.Maths.* notation is not working???????
Please help, I had wasted 1 day on this.
Thanks in adv.
- 10
- How can i get the the data come from severlet?Hi,
That's the suituation.
There's a website using servlet to provide some information i need. I
can only get the html they provide for me. Their data will be update
every minite, but i can not stare at it and push "reload" button to get
the new data.
How can i get the data using a Java class from the website
automatically per minite without do the tedious work above.
Any idea?
- 11
- J2ee: need another pair of eyes.
DaLoverhino wrote:
> Hello. I am trying to learn J2EE. I've been poking around with the
> following which seems like an infinite loop. I know I must be doing
> something simply stupid, but I can't figure it out. Anyways, my
> welcome-file, welcome.jsp forwards to gatherer.jsp which then forwards
> back to welcome.jsp. Sounds like an infinite loop, but welcome.jsp
> checks to see if a string is null, and this string is suppose to be set
> in gatherer.jsp.
>
> Anyways... here's the code (welcome.jsp, then gatherer.jsp):
>
Anyway, what exactly is the error, you did not mention.
> <jsp:directive.page />
>
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
>
> <html>
> <head>
> <title>Passing stuff around.</title>
> </head>
>
> <body>
>
> String user = (String) session.getAttribute("user");
> if( user == null) {
> <jsp:forward page="WEB-INF/gatherer.jsp">
> <jsp:param name="doWhat" value="getName" />
> </jsp:forward>
> }
> else {
> out.println( "Hello there, " + user + ". Nice to meet you.");
> }
>
Where are the JSP scriptlet tags. I assume you have them but did not
post here. If not, add them.
>
> </body>
> </html>
>
>
>
> Now gatherer.jsp which is in WEB-INF subdirectory:
>
> <jsp:directive.page
> errorPage="/WEB-INF/errorPage.jsp" />
>
>
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
>
> <html>
> <body>
>
> <%
> String actionCode = request.getParameter( "doWhat");
> session.setAttribute( "user", new String("Fred Flintstone"));
> out.println( "The action requested was : " + actionCode + ". Heck
> yeah.");
> %>
>
> <p>Go back to <a href="welcome.jsp">welcome page</a></p>
> </body>
> </html>
>
>
>
Not really an endless loop if the value is being assigned properly. Any
diagnostic messages, any logs that are not being printed ? Post them
here.
Also, no need to keep the gatherer in Webinf folder. take it out.. keep
it in your webapps/myproject/ folder. Assuming that you are using
tomcat.
- 12
- Orion - need to add customer parameterHi,
I have a large application which I need to split into 2 and put on
different servers because the applicaiton is becoming too big.
What I need is to add in a parameter which tells me if its Application
A or Application B.
Both applications will have the same code. The only difference is that
when you log onto the system it will some how read the parameter to let
it know which Application it should be and then it will display the
relevant menus. So if the parameter in one of the Orion says 'AppA'
then it will display Application A's menus and vica-versa for
Application B.
Can someone tell me which place is the best to place this parameter?
(e.g. application.xml)??
Also how would I read this parameter?
Please give example if possible.
Thanks
Simon
- 13
- newbie to javahello,
In following code there is a abstract class so i am not allowed to
create instance of class.
so Figure f = new Figure(10, 10); is wrong but why following statement
is valid?
Figure figref;
CLASS CODE =>
abstract class Figure {
double dim1;
double dim2;
Figure(double a, double b) {
dim1 = a;
dim2 = b;
}
abstract double area();
}
- 14
- PrintStream to Writer"karl wettin" wrote:
>
> Java programmers,
>
> I've wrote this software that prints output to a PrintStream (usually
> System.err), but from time to time I would like to send the output to
> a Writer (ServletResponse.getWriter()) instead.
Change your logic. Write your software so that it always writes using a
Writer. In case you need to write to an OutputStream, use an
OutputStreamWriter.
Writers are newer than OutputStreams (added in Java 1.1). Because of
this, Writers know about OutputStreams, but OutputStreams don't know
anything about Writers. So the only bridge between them is a Writer
(OutputStreamWriter) that knows about an output stream.
> {
// > PrintStream out=System.err;
Writer out = OutputStreamWriter(System.err);
>
> void someMethod(ServletResponse reponse)
> {
// > this.out = new SomeStreamWriterWrapper(response.getWriter());
this.out = response.getWriter();
> }
> }
- 15
- Instantiating a class read in from user inputI am trying to write a simple application that will instantiate a class
whose name is read in from user input. Since the name of the class is being
read in as a String, how can it be instantiated? For example, suppose I
store the name of the user supplied class in a String variable called
ClassName. I can't simple just instantiate the class with a statement such
as new ClassName(), since ClassName is a String. Any advice?
|
|
|