permaculture playing cards*
The moose likes Servlets and the fly likes Problem in accessing the class methods Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Problem in accessing the class methods" Watch "Problem in accessing the class methods" New topic
Author

Problem in accessing the class methods

Sutharshan bala
Greenhorn

Joined: Jul 31, 2008
Posts: 7
Hi friends,

I'm using a applet and java class files in my application including the servlet. The database connection and the sql querys are written on a standard java class file. I'm going to host all the files in the same server. Now what i need is i need the servlet and the applet to access the java class file methods and also i need the applet to access the methods which are written in the servlet. Please let me know is it possible and also let me know how to do this.

If you know any other solutions please let me know.
Thanks in advance


Sutha
Amol Nayak
Ranch Hand

Joined: Oct 26, 2006
Posts: 218
Sutharshan wrote
also i need the applet to access the methods which are written in the servlet


Which methods of servlet do you want to access? If the method has some business logic you can move it out of servlet into a java class. Its not a great idea to create an instance of the servlet class and invove some method on it.
Please revert back and give some more details of your requirements so that we can work out on some approach.
Sutharshan bala
Greenhorn

Joined: Jul 31, 2008
Posts: 7
sorry for the error in the post friend.

I need the servlet and the applet to access the java standard class methods in the same server, which contains the database details.

Also i want to check the user login details in applet, but i cant use session inside applet. So i need to check the session in jsp or servlet and pass that to applet via a method. Hope the problem is clearly explained now.

Give me some idea and sampLe code to handle this issue.

Thanks in advance
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Server side classes are kept under WEB-INF, a directory that is not accessible to your client side code. This means that you can't use the copy of a class file for both the client and server.

You might need to make copies of the classes that are needed by your applets and place them in a directory that is accessible to the web.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Problem in accessing the class methods
 
Similar Threads
SCJP Java 6 , Study Guide, Chapter 10:Development, Self-test question 11
Invoking a method in WSDL file from client class
Applet always use same Resource file
Plug-in/signed applet issue
Jar Structure - Right ?