简体   繁体   中英

Using .JAR file within Web Application

I am trying to learn how to develop web applications and I am a little stuck.

I want to create a movie review application. It has a few java class/packages which is inside a JAR file: moviewebapp.jar package - moviewebapp.movie class - Movie.class

package - moviewebApp.servlet MovieServlet.class

And a servlet class which has methods such as doPost, doGet, getMovie, updateMovie etc.

I have added the .JAR file to my build path.

I have developed a simple page where a user can click add movie review, which opens up a form where they can input the movie name and rating.

I now want to save the users input to a datastore. How do I use the methods within the servlet class in my javascript to deal with the post of the information about the movie?

I have tried doing imports and then trying to create a servlet object but I dont think I have the correct syntax or maybe thats not how I'm meant to do it.

Any help would be appreciated!

Jars are libraries you should not modify its code unless untill it is last option. You can import it's classes and use methods of those classes. By your question it seems you are new to Java. So I suggest you should start with hello world tutorials of servers and jdbc then start developing applications. Good luck.

Trying to provide some guidance:

Easiest solution (not the best) : you have to submit your page to receive the entry from the user. Doing this you are going to lose the status of the page on the client side.

A better solution is to make a asynchronous javascript request to get the answer provided by the user for you to process on the server side.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM