Java to a web service and mysql [closed] - java

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I'm here to pose a kinda noob question, so please no hate here mates.
The java application I'm trying to create has the following structure.
login request via net Validation(same machine)
**JAVA PROGRAM** ---------------------------------> **WebService** ---------------------------------------> **db**
Response Response
**db** --------------> **WebService** ----------------> **JAVA PROGRAM**
But my doubt is on how to build that webservice.
I've watched several glassfish tutorials, but none of them seem to explain how to actually create this type of connections.
Thank you!

You should divide your problem into several sub-problems and then tackle them one by one. I'm not sure if I understood your setup correctly, but to me it seems like you need the following:
Client Java application and the application logic
Server Java application and the application logic
Database
Connection from the server application to the database
Connection from the client Java application to the server application
In addition, you need to decide what kind of a connection you are going to use between your client and a server. Would it be a SOAP-based web service, a ReST service, plain HTML, just a simple POST/GET, or something else? Also, what kind of frameworks are you using? Spring, perhaps? Wicket? Something else?
Do you have any of those decided or done yet? Feel free to start a new question, I foresee this one being closed in the near future, because it's not clear what you are asking. Do study the What topics can I ask about here? page. If you can show any code in your question, you are much more likely to get answers.
Anyway, to give at least some kind of an answer to your question, I'd use the Spring Framework. Google for spring sql tutorial and then either spring restful web services tutorial, spring servlet tutorial or spring soap web service tutorial based on your technology of choice.

Your database interaction will be same as normal does. You just need to broadcast your Validator class as a WebService.
Below links will help you to do so.
For connecting java class with MySql
For broadcasting your class as Webservice.

Related

Will WebSocket achieve what I'm trying to do? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I'm creating a simple java application made in swing that communicates with a database. Multiple people will be using the application at the same time. As they are able to change things at the same time, if someone for example, adds a new user, and a different person is on that same page, I want the person who did not make the change to be notified that changes were made to the database since they last loaded it.
My lecturer in college advised me that WebSockets would be the way to go to achieve this, however after some reading about WebSockets in Java, it seems it is based to work with web browsers instead of between Java applications.
Can using WebSockets achieve what I am trying? Or, if not, what would be a way to achieve this?
Simple answer is Yes you can achieve what you needed
WebSocket is a communication protocol(#see RFC 6455) & it is not a must to use a Web browser.
You can achieve what you want to do with your app, it is just a matter of writing a custom WebSocket server to facilitate your requirements in your case sending database changes to the other clients(Which is called Server push)
There are several java libraries to get the work done,
netty WebSocket (My favorite)
jWebsocket
Atmosphere
Webbit
Netty WebSocket is a good one to start with and you can find examples in its project to write a custom client and a server

How to make java website [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I want to make HTML website of course using CSS etc. But instead of using php for dynamic functions I would like to use Java. I have heard that there are plenty of web frameworks as Spring etc.
The problem is always when I search for tutorial - How to make java web? It shows me results with - web application, applet, servlet, JSP. I can't find short simple answer explaining how to start with that and what is the right thing to start with.
Would you mind telling me what should I use to make what I want? Just some short answer explaining what is what for. I remind you: I want to do some dynamic stuff on web based on Java instead of PHP.
EDIT:
I know I have to use dedicated server with Tomcat probably I am just looking for way to start. Should I start with the framework or?
I personaly only used Thymeleaf tutorials to learn about java-web and I'm satisfied with them, it has good-explained tutorials but it mostly teaches you how to process html templates with java.
If you do not want to follow thymeleaf tutorials, you should search for JAVA EE or JSP tutorials on either google or youtube, both provide well explained video tutorials for beginners
For my webserver I used tomcat which is easy to use and good with debugging. I recommand it
EDIT: A web application may have one or more jsps (java server pages). Servlets are requests from the browser to the jsp.
You must have VPS or Dedicated Server to use, because shared web hostings doesn't support languages like Java, C, C++, Node.JS and so on...

How to write web services with Java [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
I usually write my web services using PHP + Mysql, in a simplified way: reading the POST/GET params, connecting to the MySQL database and finally printing a JSON.
I'd like to check how to do this with a Java server, I've never programmed Java web servers and I'd like to know what should I study to learn to do it
Thanks
I'm supposing here that you have a good understand of java programming.
Fisrtly, I think you should understand java for web.
I recommend this book:
Head First Servlets and JSP
http://www.amazon.com/Head-First-Servlets-JSP-Certified/dp/0596516681/
Then you can learn web services with java:
Java Web Services: Up and Running
http://www.amazon.com/Java-Web-Services-Up-Running/dp/1449365116
Of course, there are many tutorials over the internet as well, but books give you a lot of background information.
I wanna suggest you garner understanding of the two main WebServices Architectures then decide which ones suit your case/use best
REST (GET,PUT,POST,DELETE,PATCH) JAX-RS
http://docs.oracle.com/javaee/6/tutorial/doc/giepu.html
vs SOAP bases JAX-WS
http://docs.oracle.com/javaee/5/tutorial/doc/bnayn.html
Comparing them:
Main differences between SOAP and RESTful web services in java

Server Side push [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
how can we do server side push?
There are multiple ways to do server side push, main technologies are Long Poll and Web Streaming. However, with advent of HTML5, web socket is a good option. Beware: Not all browsers are HTML5 ready.
Read more on web-socket here
For Comet or Long Polling you can see discussion here: Best solution for Java HTTP push (messaging)
you can use JWebSocket which is open source and websocket that will do server side push based on HTML 5 specification.Hope please check this link http://jwebsocket.org/. Hope this will help you
long polling.. here is the article about server push with gwt http://code.google.com/p/google-web-toolkit-incubator/wiki/ServerPushFAQ . Bu the concepts are valid for other client side technologies..
Is it true that you are in a HTTP environment as GUrsel and UNNI assume?
In this case they point in the right direction. "Long Polling" or keywords like "Comet" and "Bayeux" should give you a good start to select a HTTP based protocol.
WebSocket seem to get the upcoming standard in the upcoming world of HTML5. As this is a quite interesting technology, many implementations exist already BUT are not yet standard!! You should also consider that major browsers have stopped Websocket support recently because of security issues.
In any non HTTP protocol environment, please clarify your question.
If anyone is interested in a Java implementation I just wrote a sample app and a blog post about it. It uses Java, Maven, Comet, Bayeux, Spring.
http://jaye.felipera.cloudbees.net/
http://geeks.aretotally.in/thinking-in-reverse-not-taking-orders-from-yo

Web services(SOAP based/Restful) [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I want to learn Java WebServices. I read couple of articles on IBM developer works but I think I am getting confused about where to start. My main interest is Restful webservices. Where can i start from? I also prefer book with web service development example based on eclipse platform.
I always find very useful response from this site and always respect the people who responds to all these questions, so as always this time too I am expecting top answers.
Thanks a lot
The Spring Framework has great support for RESTful web services in java. It is a huge library for web development in Java so it might be a bit heavy handed. However, in my experience you eventually end up needing a lot of what's provided by Spring whether you plan on it or not.
http://static.springsource.org/spring/docs/current/reference/mvc.html
So with Spring Web MVC, you can create web controllers that handle requests in a really clean way, something to the effect of (but not tested for exact correctness):
#Controller
public class PetController {
#RequestMapping("/pets/{petId}")
public void findPet(#PathVariable String petId) {
// implementation omitted
}
}
In terms of learning about RESTful web service design, I'd suggest RESTful Web Services by Richardson, Ruby, DHH.

Categories