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 am a novice programmer and would like to develop a desktop application on JAVA "Bus Ticket Reservation". Multiple device may access from different places in this system. I have no idea in networking communication programming. Please help me with some topics:
what technique should i learn to communicate with server from different computers to book or check a query ???
is it related with database?? should i use mysql database to track the booking?
May be i asked dumb question, please give me some advice and if there any good tutorial.
Since you want to develop a desktop application, you should realize that database is going to be the important component of the application. The outline of steps which you must follow are -
Develop a GUI interface which you will need to distribute to users and will serve as client application. Some basic features which you can provide in the client GUI would include choosing unique identifier (like username), entering booking details, looking at booking history and allowing cancellation.
Develop a database backend which is capable of handling this data. The corresponding tables include - users, bookings and cancellations.
Use JDBC to connect your java application with the backend.
This task does not require knowledge of socket programming. It just requires basic GUI development skills and connecting the application with database using JDBC. You may choose MySQL or PostgreSQL as the backend database. Netbeans IDE provides excellent support for GUI development (Drag and Drop) and you should use it to reduce your development time. For connecting to MySQL through Java, you may go through this link - http://dev.mysql.com/usingmysql/java/ or google for plenty more.
SYNCHRONIZATION
Create a 15 minutes ('t' in general) timeout thread which is initiated once the user submits all the details. You should update the database by reducing the quantity of available tickets for this session. You can also maintain a table which stores active bookings. Within these t minutes, if the user confirms booking, remove the entry from active booking. Otherwise, add the ticket quantity back to available tickets and terminate the session. This is the simplistic way to implement it. http://in.bookmyshow.com folllows this model.
For Desktop application in networking field learn socket programming or FTP(File Transfer Protocole) and RMI( Remote Method Invocation)
Related
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 2 years ago.
Improve this question
I have a device that sends data to a FTP server. In OM2M, I want to implement an IPE to access this data and send it to MN-CSE.
Currently I am fresher on oneM2M standards And as per the below reference I found the 2 alternative for this task.
The ftp server notifies your AE (it is constrained for us to not to make any change on FTP server configuration so we are unable to go with this approach)
Your AE implements the ftp server and would then be able to directly react on new data events.
Here I just want to adopt the second approach so if possible can I get any reference so that I can proceed with that as there is not such documentation available that I found on Internet. Or kindly mention if there is any other approach that best suits to oneM2M standard for this issue.
And I just want to get confirmation that if we are monitoring FTP server periodically for the incoming input file and then process them and send them to MN-CSE then whether this approach suits to oneM2M standards or not ??
OneM2M: IPE that periodically fetches device data from FTP server
This question is indeed about different integration options. In general, it is one or more Application Entities (AE) that operate with the resources / data in a CSE. Every tool, application, protocol gateway, or "adaptor" is, from oneM2M perspective, an AE.
A special form of AE is the IPE, the Interworking Proxy Entity. It is used to connected another system or infrastructure to a CSE and mediate between these two worlds. The CSE part, ie. the protocol and the data formats etc, are covered by the oneM2M specification, and the other part must then implement the other protocol and technical specifications. The actual task is then to convert the data and expected behaviour between both worlds.
I am not sure from your description whether what you are planning is such a protocol "gateways", or just push the data received via an ftp server to a CSE. But technically, this doesn't matter much for the oneM2M part: You need to define how the data is structured on the CSE etc anyway.
For the data retrieval: As you mention in your question there is a third option to the other two:
The AE monitors an external system for new or updated resources, and pushes them to the CSE as soon as when they are ready.
From oneM2M's perspective this is completely fine. Technically you must make sure how to find out when the data is new, completely received, still valid, etc. ... basically all the challenges when you are polling resources. The first two options would be more helpful because you would avoid some of the problems that come with polling, but as you wrote sometimes you just don't have control about the system you want to connect to.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 months ago.
Improve this question
I've almost 'finished' my first website. Which consists of an authors anthology, essentially 100's of pages containing individual articles. It's built with HTML and CSS.
At the bottom of each page I want to link to related pages, displaying the title and an image. How can I auto-populate these boxes by fetching related pages from a database?
I'm just looking for someone to point me in the right direction, I will try to teach myself. I assume there would be some server side scripting? or loading the data into a sql?
There are two approaches.
Lets compare and contrast!
1. Server Side:
You write code on the server (in PHP or Python or Java or whatever) to create HTML files programmatically, which will have the relevant links.
Pros:
You are in full control
Cons:
Resource intensive (relatively speaking)
Longer initial loading time (waiting for server to create a new page, per request)
It's the way it was always done.
2. Client Side:
You write code on the client (browser) that receives from the server just the data (perhaps JSON?), and figures out how to display it on its own. Perhaps using Angular, or React.
Pros:
Very light-weight on the server
HTML pages can be hosted cheaply (S3, DropBox, what have you)
Cons:
Content is fetched and analyzed on the fly, making the page feel slow if you're not careful
Bloats the front end, kinda harder to grasp
As a sub-topic of the Client Side, There's a new hotness in town, and it's called Serverless. You don't have to write a back end, and you focus 100% on the front end.
If you really have to make calculations outside of the users browser you can use cloud functions (like Amazon Lambda), but I don't think that's your use case.
For your use case, you can access a database straight from the front end, without needing any back end. See: Firebase.
You'll need some sort of server side program. Something that can query the database, then return the results either through an api or process it all server side and return the html. Below are some frameworks that can help.
Java:
Play, Spring, Javalin, Dropwizard, etc.
Python:
Django
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 3 years ago.
Improve this question
I would like to create a simple HTTP server in Android for serving some content to a client.
Any advice on how to build the server or use any existing library?
Consider this one:
https://github.com/NanoHttpd/nanohttpd.
Very small, written in Java. I used it without any problem.
NanoHttpd works like a charm on Android -- we have code in production, in users hands, that's built on it.
The license absolutely allows commercial use of NanoHttpd, without any "viral" implications.
This can be done using ServerSocket, same as on JavaSE. This class is available on Android. android.permission.INTERNET is required.
The only more tricky part, you need a separate thread wait on the ServerSocket, servicing sub-sockets that come from its accept method. You also need to stop and resume this thread as needed. The simplest approach seems to kill the waiting thread by closing the ServerSocket.
If you only need a server while your activity is on the top, starting and stopping ServerSocket thread can be rather elegantly tied to the activity life cycle methods. Also, if the server has multiple users, it may be good to service requests in the forked threads. If there is only one user, this may not be necessary.
If you need to tell the user on which IP is the server listening,use NetworkInterface.getNetworkInterfaces(), this question may tell extra tricks.
Finally, here there is possibly the complete minimal Android server that is very short, simple and may be easier to understand than finished end user applications, recommended in other answers.
Another server you can try http://tjws.sf.net, actually it already provides Android enabled version.
If you are using kotlin,consider these library.
It's build for kotlin language.
AndroidHttpServer is a simple demo using ServerSocket to handle http request
https://github.com/weeChanc/AndroidHttpServer
https://github.com/ktorio/ktor
AndroidHttpServer is very small , but the feature is less as well.
Ktor is a very nice library,and the usage is simple too
You can try Restlet edition for android:
The source can be downloaded from Restlet website:
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've been going through a very frustrating time trying to distribute my program and I could really use some help.
So it all started a long time ago when I decided to try and teach myself C++. I thought I'd learn by doing by trying to create a text adventure with basic code. I managed to create an executable file that worked and cheerfully submitted it to a website that sometimes hosted content similar to what I created.
My submission was rejected out of hand, as no one wanted to advertise or even open the contents of a link to a file download from an unknown source. I found some information online saying that by using the Java Programming Language, I could run an application from a webpage using something called an "applet" that other people could access.
So I learned a second programming language and some basic html and tried to put my application on a website... Except it turns out that applets are a dying technology that no one trusts and that while it is possible to run a program as an applet (or a java web start application) from a webpage, modern browsers will scream bloody murder at anyone who tries to do so because applets are considered horribly insecure.
This project has now been ongoing in some form or another for over a year at this point, and I am at my wits end. I really, really don't want to have to write my program over again in yet another language just so that I can show it to people without them flipping out and acting like I'm trying to infect them with a virus. Is there any way at all to have people use my Java program for free on the internet in a way that won't give people terrible security messages?
It's not a question of programming language. As long as your goal is to distribute your code (meaning that users have to download your code and run it on their computers) you will face the resistance. I, for one, would not run anything downloaded from internet until I research it and find reputable evidence of it being legit and harmless.
You may want to have it as a web application that runs on your server and gives users options to download results in some acceptable format. PDF is usually considered safe, though it's possible to embed maleware there.
Java EE gives many options for creation of such app, starting with JSP (Java Server Pages) and including more up-to-date ones (JSF and such).
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 need to create a server which initially checks an Android applications trial period, so
on running an Android application the phones info is sent over to ther server.
The server stores this information.
Whenever the application is opened within that android phone
the server checks its trial period has or has not expired.
In a way it's like an Android time bomb.
I'm completely new to servers and really just want a basic, secure, server that simply registers a phone and compares it against a trial limit.
Anyone have any information on how I could do this?
Any code examples or tutorials are very much appreciated.
You didn't specify your server technology, but in principal you need to do the following:
You probably want to expose them as a REST Webservice. All you need is a GET operation to basically figure out if the trial has expired or not. Since you are using Android and have gained familiarity with Java, I suggest you look at JAX-RS which is one way to implement REST in Java. If you are familiar with other language, then feel free to go for that.
The simplest form of your GET URL would probably look like http://yoursite/getTrial/[beginTrialDate] where [beginTrialDate] is a date in millis since Jan 1, 1970 GMT (standard approach)
On the server side, you simply took the [beginTrialDate] and check if it has exceed your trial period by comparing current time to [beginTrialDate] + [trial period]
You would then return a simple JSON response containing the information whether the app has expired or not. The simplest form would be: { "hasExpired" : true/false }
You would call this WebService in Android using HttpClient as you would probably know already. Check this HTTP Client Tutorial
You could make the server more robust by storing the phone identifier and your GET URL change to http://yoursite/getTrial/[phoneID]. The only additional complexity is you have to look up the begin trial date by phoneID and then compare it again using the step #4
Let me know if you need more clarification and I will add it to the post
Easiest way would be write a JSON service. here is a link to a sample PHP JSON service - http://davidwalsh.name/web-service-php-mysql-xml-json
You can easily find JSON code for your choice of language.
I'm guessing that you dont need the service to return lot of data - probably a flag or minimal data. You could simply parse through the JSON string that is returned to the device. If you have lot of data to be passed, you could try some free JSON libraries available