0

I am trying to build my very first Servlet and i am unsure of how to start.

I have a RESTAPP/Web Pages/farmacies.html page that has three search fields (city,company,farmacyname) as parameters to search in a MYSQL database using JDBC and return results as JSON.

I have RESTAPP/src/client/ApotekService.java

What am i supposed to do in doGet besides request parameters? Right now doGet is empty...

And doPost is supposed to use JDBC to retrieve things from MYSQL database, right?

How do i start with this?

Any help greatly appreciated!

thelastchief
  • 211
  • 3
  • 12

1 Answers1

0

Without using any modern framework techniques, after requesting parameters in your doPost, you will compose a SQL query statement with those parameters and feed the stmt to mysql by jdbc. You should then use the returned results to form a json string as output.

Jerry
  • 98
  • 1
  • 9
  • Thing is i am very novice, so for e.g. how do i request the parameters that will be entererd in my form: Edit: How do i connect the html file to the servlet.java, how do they communicate as two seperate files? – thelastchief Dec 05 '16 at 05:01
  • In your jsp/html form:
    , see the "action" attribute points to your servlet with POST "method". Meanwhile, you need to define the servlet-mapping in the web.xml, which answers your edited question. This [example](http://met.guc.edu.eg/OnlineTutorials/JSP%20-%20Servlets/A%20servlet%20example.aspx) should give you a heads up direction
    – Jerry Dec 05 '16 at 05:45