i am in a doubt of is it possible to call a java class in servlet?,actualy this is what i am doing but i dotn have any idea onto is this possible or not?
i have created 4 things first html page which calls jsp page in which i am calling my Servlet and in my servlet i have placed code which calls one java class and forwards to another Jsp i am getting another JSp but my java class is not called
may be all this sounds a bit confusing all in all what i am trying to achieve is calling Servlet from JSP passing parameters to Servlet and from Servlet passing parameters to my Java class which connects to the databse and saves the user input in table below is my code can anyone help me onto what i am doing does it go in right direction? i dont know bcoz i am not gettng data passed by user in the table
Is the doGet method called? Is the if-condition true or false? If it is true, what happens then? Does the code in the constructor run? As it is, there's no way to check whether that's the case or not, so how have you established that it's not running?
actualy i have created a JSP from which i am calling this Servlet and also doGet method is called bcoz i have used it in my JSP .
i think Sudhir is right bcoz how will the main method be called ?i was wrong but now i have made those changes but still i am not getting my data in the database table is there any changes i must make in web.xml so as to include java class in that servlet
please any help on above will be great
thanks in advance.
Joined: Mar 22, 2005
actualy i have created a JSP from which i am calling this Servlet and also doGet method is called bcoz i have used it in my JSP.
I don't understand what you mean by this. You don't "call" a servlet from a JSP - do you mean forward, or include, or redirect?
Furthermore, the doGet method is not used in a JSP. (To be more precise, one is being created behind the scenes by the servlet container, but there is none in the JSP, nor would your code use it.)
i think Sudhir is right bcoz how will the main method be called?
Indeed, main methods have no meaning in servlet containers, and won't be called.
is there any changes i must make in web.xml so as to include java class in that servlet
No. Your class will be used if the code is being called properly. That's why I asked the various questions above. Answering those will help us pinpoint the problem.
Also, how is the servlet being called - with which URL, and which parameters?
Joined: May 08, 2007
hey! Ulf Dittmer
you are absolutly right i have used redirect() in My JSP below is the code for it Testing.jsp gets the values from html page using request.getParameter method in my html i pass three values firstname ,email and password
test is the name of my Servlet below is code for it
below is my code for Connect.java which connects to database and inserts value in table
Rather than post your code over again, go back and answer each of Ulf's questions. People will be much more likely to stick with you until your problem is solved if you're careful not to ignore questions that they've asked when trying to help you.
Answer them all to the best of your ability. If you don't understand one of his questions, let him know so he can re-phrase it.
I do have a suggestion to you. I know you are into the beginning level of Servlets and JSP. And i have been seeing a couple of posts from you in the very basic stuff which certainly shows that you lack in the *fundamental concepts* of the technologies.
Better spend some time and read the concepts clearly. Once you understand the basic working model of the technologies, you yourself will get rid of the small issues.