• Post Reply Bookmark Topic Watch Topic
  • New Topic

servlet or jersey api or both ?

 
alex friday
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
I need some explanation for my purpose and I hope I will find the needed help here.

I want to implement an Restful bus tracker based on crowdsourcing. It will record data like long, latit, mac, route from the bus riders and send it to the server. The waiting rider can query the server for the location of their desired bus route. The result will be displayed as a marker in google map.

I could accomplish the connection to the server with PHP and the data is being updated in the byethost8.com from my device.

The next Step will be to handle the waiting rider's queries and send them the right responses. My question: What are are needed apis for my approach in the server side JERSEY(JAX-RS) or JSP Servlet or both?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65530
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Will this system be just RESTful web services? Or will also have a UI?
 
alex friday
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It will be restful web services with an Android app without homepage. What do you mean here with user interface? The app is the UI.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65530
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Then you'd certainly have no need for JSP, which are templates for views.

It's been quite some time since I've look at Jersey, but if I recall you annotate classes and don't define your own servlets. But I'll move this to the Web Services forum where those more up-to-date on Jersey can comment.
 
alex friday
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
but is there need for servlet?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65530
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As I already said, I do not believe so, but do not remember for sure. If (and only if) I am remembering correctly, the Jersey implementation uses servlets internally to process the request and delegate it off to the annotated classes (Front Controller, just like Struts, SpringMVC, et al).

Check the Jersey documentation to find out for sure.
 
alex friday
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As you said I found out that jersey works internally with servlet. Last question to clear up my confusion. Does Jersey work with php together?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65530
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, Jersey is a Java system. Where would PHP come into play?
 
alex friday
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am aksing because I could accomplish the inserting/updating part of my app with pure PHP script and I thought it must play a role in the implementing later. How does Jersey communicate with mysql database and which database system can I use with Jersey?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65530
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Trying to shoehorn PHP into a Jersey Java app would be a mistake of such monumental proportions as to evade even hyperbole.

alex friday wrote:How does Jersey communicate with mysql database

Jersey doesn't. Your code does.

Jersey is a Java framework for the API of web services, You can use whatever DB you want behind that as long as it has JDBC drivers. (So, yes).
 
alex friday
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok thank you very much I got it
 
alex friday
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also the summary: I can implement restful web services with JAVA system like Jersey or with pure PHP script? I read many Anroid restful web services tutoriales and many of them work just with PHP on the the server side.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65530
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm sure you could implement a a RESTful web service with PHP, but not knowing a whit about PHP I would not know if there are tools (like Jersey) that make it easier than doing everything by hand or not. Your choice.
 
alex friday
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to get my first Jersey web service project to work but I am getting this error `Jersey: The requested resource is not available.` I have installed `Jersey 2.16` by eclispe Maven and installed `Tomcat 8.0.21` I have craeted the MessageResource.java class inside `scr/main/java - org.test.messanger`

I am typing this link:



If I klick this link I am getting `Got it!`

I added Jersy with maven with this data:

- org.glassfish.jersey.archetypes
- jersey-Quickstart-webapp
- 2.16

MessageResource.java



Working code:




web.xml



I

I dont know whether I should open a new post for it but I will post it here for now.

I am working this tutorial through:
https://www.youtube.com/watch?v=2QD1sOG8pyU&list=PLqq-6Pq4lTTZh5U8RbdXq0WaYvZBz2rbn&index=13
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!