swapna sivaraju

Ranch Hand
+ Follow
since Jan 18, 2002
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by swapna sivaraju

HI
Iam retrieving audio files from oracle database and trying to play them in a browser when the user clicks on the link of that .wav file.
But my problem is iam unable to give the filename dynamically in HTML.
eg. <a href="http://server/test.html?filename=fname><%=audioname></a>
(the fname is a variable declared in jsp.it has the actuall file to play)
Iam using embedded HTml in jsp.
Can some one tell me how to use the variables declared in JSP or javascript in HTML <a>,<embed>,<param>(of<object> tags.
Pl. let meknow if u a solution for this,
Thanks
HI
Iam unable to move /copy a file from one machine to other on the network using this code.
class MoveFile
{
public static void main(String ar[])
{
try
{
Runtime rn=Runtime.getRuntime();
Process move =rn.exec("cmd /C move C:/text.txt I:/Test/text.txt") ;
move.waitFor() ;
}
catch(Exception e)
{
System.out.println("Error"+e);
}
}
}
Where C is the localdrive and I: is the mapped drive of the second machine.
This code doesnt throw any Runtime exception but the file is not coppied .

Thanks
Swapna.
20 years ago
Thanks i could solve this..i think there was some problem with the format of *.gif files.
When i loaded the files again,it worked.
20 years ago
HI,
The files are in right path and the extensions are also correct.
help me out with this as iam unable to get the
reason of this odd behaviour.
Thanks
Swapna
20 years ago
HI
Iam trying to display images on my ToolBar buttons.
The First button gets the image(1.gif) but no images are displayed on the rest of the buttons..can anyone tellme the reason.
Here is the code--
Class TestClass extends JFrame
{
JToolBar toolBar;
Action Button_1,Button_2,Button_3,Button_4;
public TestClass()
{
super();
toolbar =new JToolBar();
Icon ic1=new ImageIcon("C:\\1.gif");
Button_1 = new AbstractAction("1",ic1) { public void actionPerformed(ActionEvent e) {
}
};
Icon ic2=new ImageIcon("C:\\2.gif");
Button_2 = new AbstractAction("2",ic2) {
public void actionPerformed(ActionEvent e) {
}
};
Icon ic3=new ImageIcon("C:\\3.gif");
Button_Save = new AbstractAction("3",ic3) {
public void actionPerformed(ActionEvent e) {
}
};
Icon ic4=new ImageIcon("C:\\4.gif");
Button_Print = new AbstractAction("4",ic4) {
public void actionPerformed(ActionEvent e) {
}
};
toolbar.add(Button_1).setToolTipText("1");
toolbar.add(Button_2).setToolTipText("2");
toolbar.add(Button_3).setToolTipText("3");
toolbar.add(Button_4).setToolTipText("4");
getContentPane().add(toolBar);
pack();
setVisible(true);
}
public static void main(String sr[])
{
new TestClass();
}
}
The *.gif files are in the same directory as the class files.
Thanks
20 years ago
Yeah thats right i figured out that i didnt copy MailClass to the same directory.

Thanks
21 years ago
Hi
Iam trying to execute this code but its generating an exception..can someone let me know the cause of it.

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.util.Properties;
import javax.mail.*;
import javax.mail.internet.*;

public class SendEmail extends HttpServlet
{

private String msg,str;
public void init(ServletConfig config) throws ServletException
{

}

public void doGet(HttpServletRequest req,HttpServletResponse res) throws ServletException,IOException
{
msg=req.getParameter("MSG");
res.setContentType("text/HTML");
try
{
MailClass m=new MailClass(msg);
str=m.sendmsg();
PrintWriter out = res.getWriter();
out.println("<Html><body>"+str+"</Body></html>");
}
catch(Exception e){System.out.println("Error1: " +e);}
}

}
class MailClass
{
String Msg;
MailClass(String msg)
{
Msg=msg;
}

public String sendmsg() throws Exception
{
String host = "w.com";
String from = "abc@w.com";
String to = "xyz@w.com";

// Get system properties
Properties props = System.getProperties();

// Setup mail server
props.put("mail.smtp.host", host);

// Get session
Session session = Session.getDefaultInstance(props,null);

// Define message
MimeMessage message = new MimeMessage(session);
// Set the from address
message.setFrom(new InternetAddress(from));

// Set the to address
message.addRecipient(Message.RecipientType.TO,
new InternetAddress(to));

// Set the subject
message.setSubject(Msg);

// Set the content
message.setText("Welcome to JavaMail");

// Send message
Transport.send(message);
session.setDebug(true);
return "Message sent";
}
}

the error it says is
Internal Servlet Error:
java.lang.NoClassDefFoundError: MailClass
at java.lang.Class.newInstance0(Native Method)
at java.lang.Class.newInstance(Unknown Source)
at com.sun.web.core.ServletWrapper.loadServlet(ServletWrapper.java:100)
at com.sun.web.core.ServletWrapper.handleRequest(ServletWrapper.java:119)
at com.sun.web.core.InvokerServlet.service(InvokerServlet.java:168)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:840)
at com.sun.web.core.ServletWrapper.handleRequest(ServletWrapper.java:155)
at com.sun.web.core.Context.handleRequest(Context.java:414)
at com.sun.web.server.ConnectionHandler.run(ConnectionHandler.java:139)
Iam using jswdk-1.0.1 as the webserver and JDK1.3.1_06.
Thanks in advance
Swapna
21 years ago
HI Guys
Iam looking for an entry level position in Java.
Iam a Masters from India ,did by graduation in
Computerscience,3 yrs course in NIIT and then later taught Java there for 1 yr. before moving to US(in 2001).
In April 2002 i cleared my SCJP2 with 94%.
Right now my search is restricted to US only.
PL. let me know if anyone has some opening for me.
Thanks
Swapna
21 years ago
hi
When u overload a method it requires changing of signature which includes name of method and parameters(which is neccessary) and return type(not mandatory ).
So when u change return type without changing the signature of the method it means u r duplicating the previous method in the same class which is not allowed during method lookup.
So here in ur example--
void f(){}
int f(){return 1;}
int f() is a duplicate of void f().
Thus,when u r trying to call the method
int n=f() ...it gives CE as it cant resolve which method u r looking up.
i hope its clears the doubt.
Swapna
HI Tony,
In ur code:
Double d=new Double(0.9);
Float f= new Float(0.9f);
d and f are two different types of objects one is of type Double and other Float and hence the tyoe of value they represent is different.Thats why
f.equals(d) returns false ..
Now secondly,
double d=0.9;
float f=O.9f;
d==f returns true.
for == operator the binary numeric promotion is applied and so when we compare double and float ..the value
of float (0.9f) gets promoted to double ..
so u get the answer as true.
This type of automatic conversion is not applicable to Object types (here it is Double and Float).
I hope u get it.
Swapna
Actually this works..as main is like any other method in a class,giving it a private , protected
wont generate any kind of CE or RE.
But for the exam point of view we need to follow what JLS says ie.

"The method main must be declared public, static, and void. It must accept a single argument that is an array of strings"
Swapna
Congrats Will...!!!good score!
Swapna
21 years ago
HI
Here the call new SubClass().g() invokes the inherited method g() from SuperClass (as g() is not present in SubClass) and then in the method
g() there is a call to f() in the statement return f()...now since f() is private in the SuperClass so the method f() of SuperClass is invoked not the one in SubClass( as u may think that u r working on the SubClass object)..Also,
u should know that private and static methods r never overridden...
In this code the method public int f() {}
is not overriding the private int f(){} in SubClass..
THats why the answer is 1.
Hope this helps
Swapna
Good luck Rob...u will certainly do well..
if not u.then who else!
Best of luck!
swapna

Good job Brian!!!congrats

swapna
21 years ago