[QUOTE=jwenting;1134187]and what is line 11?[/QUOTE]
Line no 11 is same as line no 10

hi,
i deployed a webapplication(wapp1) having input.html and a servlet(Servlet1) in tomcat web server. The form input.html just accepts a text and when u click on the button click the request is sent to servlet in wapp1. The request is redirected to a servlet(Servlet2) which is in a webapplication(wapp2) deployed on weblogic application server...the response is given to the browser using servlet in wapp2 deployed in weblogic server...but when i try to do this i get java.lang.NullPointerException...
The code is here...[CODE]
import javax.servlet.;
import javax.servlet.http.
;
import java.io.*;

public class Servlet1 extends HttpServlet{

public void doGet(HttpServletRequest req,HttpServletResponse res)throws ServletException,IOException{
    String s1=req.getParameter("uname");
    res.sendRedirect("http://localhost:7001/wapp2/srv2?user="+s1);
}//end of doGet

}

[/CODE]
web.xml is here for first servlet in tomcat
[CODE]
<web-app>
<servlet>
<servlet-name>dum</servlet-name>
<servlet-class>Servlet1</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>dum</servlet-name>
<url-pattern>/srv1</url-pattern>
</servlet-mapping>
</web-app>

//and this is input.html in web application 1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>

</HEAD>

<BODY>
<center>
<h2>
<form action="srv1">
Username:<input type=text name="uname"><br>
<input type=submit value="click">
</form>
</h2>
</center>

</BODY>
</HTML>
[/CODE]

The above code is in wapp1 deployed in tomcat server.

The following code is in web application deployed in weblogic server
[CODE]
import javax.servlet.;
import javax.servlet.http.
;
import java.io.*;
public class Servlet2 extends HttpServlet{

public void doGet(HttpServletRequest req,HttpServletResponse res)throws ServletException,IOException{
    PrintWriter pw=res.getWriter();
    String s=req.getParameter("user");
    pw.println("welcome "+s);
    pw.close();
}//end of doGet

}
//the web.xml for this servlet
<web-app>
<servlet>
<servlet-name>dum</servlet-name>
<servlet-class>Servlet2</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>dum</servlet-name>
<url-pattern>/srv2</url-pattern>
</servlet-mapping>
</web-app>

[/CODE]
The exception is [quote]
Error 500--Internal Server Error
java.lang.NullPointerException
at java.util.Hashtable.put(Hashtable.java:389)
at weblogic.servlet.internal.WebAppServletContext.setAttribute(WebAppServletContext.java:669)
at Servlet2.doGet(Servlet2.java:11)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at ...

Thanks for the replies.....

Which is the most efficient way of creating a string object in java?

[icode]String s="helo";[/icode]
or
[icode]String s=new String("helo");[/icode]

in terms of memory usage?
Thanks in advance...

[QUOTE=qutejose;1132219]Does J2EE support Enterprise applications?

Is Java Beans an application dependent components?

Does JavaBeans support sharing among the network?

1 Javabean can contain how many classes?

Does Servlets execution starts with main methods?[/QUOTE]

servlets doesnt start with main method....servlet has lifecycle methods which are executed by a web server or an application server....for resource like a servlet you deploy in the server the container(an application contained in a server)takes care of servlet...it creates object of the servlet...and provides the service.....The life cycle methods of a servlet are
public void init(arguments);
public void service(arguments);
public void destroy();
to find more about servlets see the j2ee api...that should tell you more about it....

well a java bean is a class which has getter and setter methods...with fields which are private...
J2EE technologies like(servlets,jsp,EJB(for n-tier applications)) are exclusive for enterprise applications.....

jwenting commented: don't help homework kiddos -2
peter_budo commented: Ignoring forum rule "We only give homework help to those who show effort" bad -2

Hey dude....
i will try to develop the application for you....give me a clearcut specifications of what you want me to develop and what java technologies(JEE) you want me to use....or is it just enough if i use J2SE core concepts....make sure you give me a full description of the problem....dont give me some form of vague description of the problem....hurry up....mail the problem to [I]<<Email Snipped>>[/I]
all the best...

javaAddict commented: Do you even know the purpose of this forum? -1
__avd commented: Read post #2 -1
Ezzaral commented: What do you think he will learn for that -2

Well you could do this many ways....use html form as front end and connect to some database and perform all the functionalities...or use swings and use a text file as a persistent store...how r u supposed to do this?

[QUOTE=beanboy;1125367]okay :) i wil see[/QUOTE]
tin the <servlet-mapping> tag u have <url-pattern> tag and this should match exactly with the <servlet-name> tag in <servlet> tag e.g.
in the web.xml file...[CODE]
<web-app>
<servlet>
<servlet-name>dummy</servlet-name>
<servlet-class>SomeServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>dummy</servlet-name>
<url-pattern>/heloserv</url-pattern>
</servlet-mapping>
</web-app>

[/CODE]

Here the servlet-name can be any name...but make sure it is same in both the <servlet> and <servlet-mapping> tags and the <servlet-class> should be the name of your servlet(the servlet you developed)...
and the url pattern can be anything...but if you have done hard deployment in the server...you should call the servlet in the following way....
[url]http://localhost:portnumber/root/helosrv[/url]

if you did console deployment and your war file name is something like test.war then you shld call the servlet in the following way...
[url]http://localhost:portnumber/test/helosrv[/url]...

Hope ur servlet works fine now....

[QUOTE=peter_budo;1125362]2 possible issues:
1)You didn't point compiler to the location of servlet.jar file (which should not be this case if you used appropriate project)
2)Your files can no longer find each other as you may not keep folder structure as on compile

If you want to compile from command line you can use following [URL="

[QUOTE=beanboy;1125319]do i need a Java Studio Creator to compile my servlets,.... i'll check it anyway[/QUOTE]
You don't need a java Studio creator to compile your servlet...just copy paste your servlet in a text document,or edit plus....go to the command prompt and set the path to your j2sdk/bin and compile the program using javac command....it shld work....and just copy the .class file into classes folder....thanks....

Otherwise u do one thing....compile ur servlets .java files and place the .class files manually in the WEB-INF/classes folder then it shld work...and one more thing...did u make ur servlet public?....

Well..... My attitude is very fine and pretty good!!!........It is easy to give suggestions to others....well i am saying it again...its upto me to post a thread or not....Mr.BJSJC can never ask me to go and check out in google b4 posting...guyz if u have posted some question here and i say go and check out in google b4 u post this here(u might get offended).....bcoz it happened to me everyone gives deaf year and give some suggestions......

Hi you should take a little bit pain to tell me what type of arrays are you taking and what is the if condition doing there?.....If you post the question in a vague form no one will first understand ur question to help you...thanks...

Hey Mr.BestJew you need not tell me to google or not google before posting a thread.......stop giving ur crap suggestions.....its upto me to post the thread or not....

jwenting commented: insulting other members isn't going to make you friends. -2
stultuske commented: it's not a "crap suggestion" at all -1

Well...this is a code snippet to connect to oracle data base using type-1 driver using your java program:...hope this helps you......

import java.sql.*;
class DbConnection 
{
    public static void main(String[] args) 
    {
        try{
        Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
        Connection con=DriverManager.getConnection("jdbc:odbc:Fardoon","scott","tiger");
        DatabaseMetaData dbmd=con.getMetaData();
        String str=dbmd.getDatabaseProductName();
        System.out.println("The name of the database you are using is: "+str);
        con.close();
        }//end of try
        catch(SQLException e){
            e.printStackTrace();
        }
        catch(Exception e){
            e.printStackTrace();
        }

    }//end of main
}//end of class

1.Class.forName() method loads and registers the jdbc type-1 driver named sun.jdbc.odbc.JdbcOdbcDriver
2.DriverManager.getConnection() method The attempts to select an appropriate driver from the set of registered JDBC drivers
3.The DatabaseMetaData is an interface and is used to find the details of the
database you are connected to....
I used the DatabaseMetaData to confirm that you are connected to the database.
//"Fardoon" is the dsn name(userdefined) u create to connect to the database using the ODBC connection for oracle

you create an user dsn(data source name) by going to control panel->Administrative tools->Data Sources(ODBC)->Go for Add->select Microsoft ODBC for Oracle->select finish->then you get a dialog box and enter only the dsn name(ignore other text fields) and select ok...you can see the new dsn name in the user dsn list newly created...

There is always a Why to everything...and definitely there will a reason behind it...Mr.Java Addict

By googling i found out this answer :
The authors of the Java language took a design decision to compromise multiple inheritance with interfaces, the specifics of this decision may be covered in other sources. Practically, multiple inheritance is difficult because of the ambiguities it can create when a class inherits from two superclasses with the same method signature: which version should be called?

Well i am not sure if we can directly call a user-defined method of one servlet from another servlet....but we can achieve this in this way....I have defined an user defined method in servletB and called it in doGet() lifecycle method of SerletB and from the ServletA's life cycle method i created a RequestDispatcher object and used the method rd.include(req,res)...and it worked fine.....Here's the code...
[code=java]import javax.servlet.;
import javax.servlet.http.
;
import java.io.*;
public class ServletA extends HttpServlet{

public void doGet(HttpServletRequest req,HttpServletResponse res)throws ServletException,IOException{
    PrintWriter pw=res.getWriter();
    pw.println(" This is service method of ServletA ");
    ServletContext ctx=getServletContext();
    RequestDispatcher rd=ctx.getRequestDispatcher("/tt");
    rd.include(req,res);
}//end of doGet

}//endof servlet A[/code]
[code=java]import javax.servlet.;
import javax.servlet.http.
;
import java.io.*;
public class ServletB extends HttpServlet{
PrintWriter pw;

public void doGet(HttpServletRequest req,HttpServletResponse res)throws ServletException,IOException{

    pw=res.getWriter();
    pw.println(" This is service method of servletB and i am being called by ServletA ");
    hello();

}
public void hello(){
    pw.println(" This is hello method of serveltB and i am being called in service method ");
}

}//end of ServletB[/code]
web.xml file
[code=xml]<web-app>
<servlet>
<servlet-name>serva</servlet-name>
<servlet-class>ServletA</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>serva</servlet-name>
<url-pattern>/ss</url-pattern>
</servlet-mapping>

<servlet>
<servlet-name>servb</servlet-name>
<servlet-class>ServletB</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>servb</servlet-name>
<url-pattern>/tt</url-pattern>
</servlet-mapping>
</web-app>[/code]
Hope this is the solution to ur question....

Why java doesn't support multiple inheritance?thank you....

Thanks for clearing my doubt.....cheers
Regards,
Fardoon

If a class doesnt override toString() method and tries to print out the object like this:
//some class
[code]
public class SomeClass1{

int x=4;

}
//another class
class DemoOftoString
{
public static void main(String[] args)
{
SomeClass1 o=new SomeClass1();
System.out.println(o);
}
}

[/code]

output:SomeClass1@hex version of object's hash code

But when a collection object is called with collectionobject.toString() it returns the values...but it doesnt return classname@hex value of objects hash code..instead it return values.....
Can anyone help with this....thanks
regards,
Fardoon.

/*this code shld work...5/9 returns 0 so use 5/9.0 which returns float value*/
import javax.swing.JOptionPane;
public class Test{
public static void main(String args[]){

String numT = JOptionPane.showInputDialog(null,"Please enter a value.");
double num1 = Double.parseDouble(numT);

System.out.println("Fahrenheite = "+num1+"\nCelcius = "+convertFtoC( num1 ));
}

public static double convertFtoC ( double num1 ){

return ((5/9.0)*(num1-32));
}
}

can anyone explain what is a lightweight application?....Thanks

The best way of programming is to make your fields(member variables) always private and make your methods public to preserve encapsulation in java. The setter(mutators) and getter(accessors) methods are used to set and get the field values by other classes. you can directly use yourobject.hashCode() to find the hash code.

Hi,
I have a doubt here, plz go thru the code snippet here:

Statement st=con.createStatement();
ResultSet rs=st.executeQuery("select * from emp");

Statement and ResultSet are interfaces. executeQuery() method of Statement interface returns a ResultSet object here. That means defnitely Statement should implement ResultSet interface methods to return a ResultSet object, but Statement is an interface, it cldnt implement another interface. Can anyone please clarify this.....thanks

GregorianCalendar(concrete class) is a subclass of Calendar(abstract class).So u can use either....So u can say GregorianCaendar c=new GregorianCalendar.......thanks

import java.util.*;
class ClassOne
{
public static void main(String[] args) 
{
int eid;
String ename;
double salary;

Scanner sin=new Scanner(System.in);

System.out.println("Enter eid");
eid=sin.nextInt();
System.out.println("Enter ename");
ename=sin.next();
System.out.println("Enter salary");
salary=sin.nextDouble();

Employee e1=new Employee();
e1.accept(eid,ename,salary);
e1.display();

System.out.println("Enter eid");
eid=sin.nextInt();
System.out.println("Enter ename");
ename=sin.next();
System.out.println("Enter salary");
salary=sin.nextDouble();

Employee e2=new Employee(); 
e2.accept(eid,ename,salary);
e2.display();

if(e1.equals(e2))
System.out.println("Both equal");
else
System.out.println("Both not equal");

}
}

/////////////////////////////////////////////////////////////

class Employee
{
int eid;
String ename;
double salary; 
public void accept(int eid,String ename,double salary)
{
this.eid=eid;
this.ename=ename;
this.salary=salary;
}
public void display()
{
System.out.println("Employee details is:");
System.out.println("\nEmp id="+eid+"\nEmp name="+ename+"\nEmp salary="+salary);
}
public boolean equals(Employee obj)
{
/*if(obj instanceof Employee)
{
Employee o=(Employee)obj;
return(eid==o.eid && ename==o.ename && salary==o.salary);
}*/
if(this.eid==obj.eid && (this.ename).equals(obj.ename) && this.salary==obj.salary){
    return true;
}
else
return false;
}
}

Dude this shld work......thanks

This works...try this

import java.util.*;
class  ScannerDemo{

    public static void main(String[] args) 
    {
        System.out.println("please enter some thing");
        Scanner s=new Scanner(System.in);
        while(s.hasNext()){
            System.out.print(s.nextInt()+" ");
        }//end of while

    }
}