• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

How to move Tomcat code in a servlet to a server.

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi everyone! I have an Android application which uses Tomcat in a servlet this way:

1. The user click on a button in the phone (the client).
2. The client sends a message to a Tomcat which is running on my personal computer.
3. The Tomcat sends a message forward to SQL server (which also in my personal conputer).
4. The SQL server sends an answer back to the Tomcat .
5. The Tomcat sends the answer forward to the client (the phone) .
Until now everything works well.

Now, I have a router which creates a little private net in my house,
so my phone and my computer are connected to the same net (this little net in my house by my router).
It means, I can use this application wireless but only inside my house (or 20 meters around the router).

The question is, what do I need to do now, in order to use this application everywhere without being depend in the distance from my router.
I guess there are things I need to do about moving to a server.
How do I move all the JAVA code (I wrote in the Tomcat side), and SQL code (I wrote in SQL server) to a server.
Thanks you,
Eliran.
P.S  As you can notice from my message, I'm not so familiar with servers  
 
Saloon Keeper
Posts: 7631
177
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you have a static external IP address you could open a port on your router/firewall to allow access from the app. That ultimately means opening your home network to the Internet, which is not a great approach for security reasons.

The other option would be to run your software on a server rented from a hosting company. In my experience, $20 per month gets you something sufficient for starters.
 
Eli Ean
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Tim, thanks for the answer. The first option sounds little bit scary so I won't use that one.
About the second option you mentioned, I've just connected an hosting company which said it is not possible to
have my application on one server because I don't use MySql  (I'm using SQL Server).
I need to have 2 accounts:
1 that will contain the tomcat server (tomcat hosting) , and then a second account will be the sql server (ASP.Net. hosting) with SQL
server on it.
This way the phone will send a message to the Tomcat in the first server, then the Tomcat will query the Db in the ASP.net server.
Sounds not the best solution for performance issue..
A better solution?
 
Tim Moores
Saloon Keeper
Posts: 7631
177
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Any particular reason for using SQLServer rather than MySQL? If you use standard SQL via JDBC, or an ORM like JPA or Hibernate, switching to a different DB shouldn't be hard.
 
Rancher
Posts: 2759
32
Eclipse IDE Spring Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
One thing you might try to do is rent a whole server rather than rent hosting for a web application. If the differrence is not clear, let me try to explain it. Usually, when you go to a web hosting provider and tell them to host your web application, they will host your web application on a Tomcat that is shared with other people's web applications. If you need a database, they will create a schema for you on a database server that is shared with other people. This is cheaper for them (and for you). Also, if one of the applications starts having more load, they can automatically deploy your application on multiple servers. This reduces your headache

What you can do is get a whole server. This is costlier. However, you will be able to install whichever software you want to install. You can install Tomcat and SQL Server yourself just like you have installed on your local machine. They will also assign a fixed IP address to the server for a price. This might be costlier, and also you will have to do the work of getting more servers when your load increases. I am assuming you are not worried about load because it;s just you using it.

Google for Windows Server Hosting. There are plenty of providers. Actually, Amazon will give you a small server for free for 1 year. Other providers have reduced introductory prices too.

The right thing to do is, like Tim said, write your code  so you can switch databases easily. If you use ORM layer like Hibernate, it isolates the specifics of the database from you. It makes your code database agnostic. You could get a server for free/cheap using the introductory offers and install your software as-is. Then you can work on making your code agnostic to the database.
 
Eli Ean
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Tim and Jayesh. Thanks for helping someone who deals with servers for the first time.
Ok, I'm using SQL server and not MySql because 2 simple reasons: My ex workplace had SQL Server, and when I started develop
the application, I naturally went to my familiar DB and it was a free version (express version).
Now it will be little difficult to move to MySql, because I have already more than 250 stored procedures which I use them.
If there isn't a simple way to convert them to MySql, I would prefer to avoid this option.

I understood It is not the best idea to have Microsoft Sql Server and Tomcat in the same server.
The reason is that Tomcat runs best on Linux OS and MS Server can not run over there, so I need to have 2 servers (and not
2 accounts as I thought before).

Jayesh, about your line:

Actually, Amazon will give you a small server for free for 1 year.


Must say sounds strange...well, do you think it is a good solution in a case I preserve my will to use Tomcat and MS Sql
for the application ? I remind this server will use only 1 client - me. All my goal for now is to be able to use thw application every place,
and not as I do these days - only in places are not farther than 30 meters from my router.

Thanks,
    eli.
 
Could you hold this kitten for a sec? I need to adjust this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic