Ray Jender

Greenhorn
+ Follow
since Jun 27, 2019
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Ray Jender

Ray Jender wrote:

Tim Holloway wrote:1. Did you configure Tomcat to listen on port 5443?

Yes.  I thought I mentioned that?

2. Did you setup an SSL keystore and define certs?

I'm not sure what that exactly means?

Until you do that, no URL path will work.

Again, like I said.   This app works as designed, using https!
I am simply trying what should be an easy modification that I cannot get to work!




I have:
/usr/local/antmedia/conf/truststore.jks
/usr/local/antmedia/conf/keystore.jks
4 years ago

Tim Holloway wrote:1. Did you configure Tomcat to listen on port 5443?

Yes.  I thought I mentioned that?

2. Did you setup an SSL keystore and define certs?

I'm not sure what that exactly means?

Until you do that, no URL path will work.

Again, like I said.   This app works as designed, using https!
I am simply trying what should be an easy modification that I cannot get to work!


4 years ago

Norm Radder wrote:Is there a window that you can open and issue the command to start tomcat so any error messages it prints out are shown?
On windows it writes lots of messages on the console window.



There are three log files that I monitor while restarting the app.  None of them are showing errors.
4 years ago

Tim Holloway wrote:Also, some general notes. Apparently some people are running this product in Docker containers. I don't know if that's an option for the Community Edition or not, but if so, it's probably going to be a lot easier to get running.

If I can get this to work,  I am considering running this in containers, sure!

I think a system I worked on about 2 years ago did something similar, but it was based on MediaTomb, which is now known as Gerbera. That was a completely non-Java system, though.

4 years ago

Tim Holloway wrote:That was rather loud.

OK, a quick trip to antmedia.io seems to be something I'd expect to be more up-to-date than CGI, but whatever.

I think the URL you want is more like https://localhost:5443/WebRTCApp/cgi-bin/hello.cgi

Tried it.  It does not work.

Which, incidentally, is more like non-Java CGI URLs look as well. Now that I think of it, my Nagios server is CGI-based.

Also, as I said, Tomcat doesn't come pre-configured to use port 5443, so you're going to either have to use port 8443 or change the Tomcat server.xml file to use port 5443. And since this is SSL, you WILL need to setup a keystore and certificate no matter which port you use.

The app come with an ssl install script, using "Lets Encrypt" and port 5443.

Also, please warn us when cross-posting to other sites/forums. It helps in keeping people from getting confused.

I thought I answered this reply already but when  I came back to read it, I didn't see any of the comments I made?   Weird.

4 years ago

Norm Radder wrote:

got the same error.


Strange.  The URL I posted does a GET not a POST.

Have you looked at the DOS window console where tomcat is running for error messages?



The apache-tomcat is running on Ubuntu Linux,  not Windows.
4 years ago

Tim Holloway wrote:OK, first of all NO Java webapp server - including Tomcat - will serve anything out of any file or directory under WEB-INF. That's defined by the 2EE/JEE standards specification. The WEB-INF directory is reserved to hold support files and other vital assets that outsiders shouldn't be able to mess around with, so it's hidden from URL web requests and so are its contents.

The How-To says something different? Have I misinterpreted it? : https://dzone.com/articles/enable-cgi-mode-in-tomcat

Secondly, jQuery isn't necessarily Java. The "j" is for Javascript, and it's a client-side library package used to support AJAX and other advanced client-side functions and features. It is very popular in Java apps, but it can be used with non-Java apps on non-java servers (such as Apache httpd server, which is a completely different software system from Apache Tomcat). It doesn't require or use CGI.

Sorry if I implied jQuery was java.  I know it is javascript and I am trying to use AJAX;

Thirdly, Enterprise Java (J2EE/JEE) does NOT work on loose collections of files. It is based on the WAR (or EAR) architecture which can be represented as a ZIP (or more accurately a JAR) file. The Tomcat webapps directory is simply Tomcat's default place to keep deployed WARs, your WAR name is WebRTCApp and what you therefore have is what is known as an "exploded" WAR, which is to say an unzipped version of what would in strict JEE terms be a file named WebRTCApp.war.

And if that sounds needlessly pedantic never forget that computers are infinitely more pedantic, and if you don't understand the rules, you're likely to not follow them correctly and you're likely to have things fail for reasons you don't understand.

It might help if you could tell us where you got that webapp from. It's probably hideously obsolete, but at least then we could figure out what it really needs.

And finally, Tomcat doesn't normally listen on port 5443. I suspect that's supposed to be an SSL port, although Tomcat's default for SSL is 8443 and only a change to the Tomcat config file will make it listen on 5443.

The app is from antmedia.io   the community version.  And yes, it's configured to run ssl on 5443.  I don't think it's obsolete.  If does what it is developed to do.  I'm just trying to slightly modify it via html and javascript.

Thanks for the response and appreciate it!



PS:  $ java -version
openjdk version "11.0.3" 2019-04-16
OpenJDK Runtime Environment (build 11.0.3+7-Ubuntu-1ubuntu218.04.1)
OpenJDK 64-Bit Server VM (build 11.0.3+7-Ubuntu-1ubuntu218.04.1, mixed mode, sharing)
4 years ago

Norm Radder wrote:Have you tried with a simpler URL: http://127.0.0.1:8080/Norms/cgi-bin/ENV2HTML.PL
I was able to configure TomCat 8.0.32 to call the perl script and return with it output to my browser



I tried that and got the same error.
4 years ago
Ok. Let me add some detail to my original question.

First I am using:
Ubuntu 18.04 server
Tomcat v8.5.38


So,  I am not a seasoned programmer.  You can say I am a dabbler.  I can stumble my through most code and get the gist of what it is doing.
If I did this for a living,  I'd know the answers myself. But I am only an experimenter.   I'm the type that likes to learn how to fix what I need to
fix, and not learn how to program the entire app.

I have taken freeware/shareware code in the past (javascript) and managed to modify it to do what I needed.   It has worked out fine for me without
actually knowing the ins and outs of programming in javascript.

In this particular case,  I have a valid/legitimate copy of an Apache-Tomcat based server application that I want to modify slightly.

The app uses googleapps.com/AJAX/jQuery

My file structure is:
 
webapps/
    WebRTCApp/
        index.html
        WEB-INF/
               web.xml
               cgi/
                 hello.cgi

I have added this to the existing web.xml:



In the index.html, at the very top of the file there is this:

 I'm not sure exactly what this does but my guess is this
page is handled by the apache-tomcat server?

...but the rest of the index.html file is html and javascript only.

I basically want to save a variable that I create with javascript inside the index.html, into a database.  Sounds pretty simple to me.  But no.
At first I thought using php/mysql.  But no, the Apache-Tomcat server the app uses does not support php as a default.

So now I am trying perl.  I am trying a very simple perl script called hello.cgi    and using the "How-To" at:  Apache-Tomcat CGI

Inside the index.html I have this:  
And when I browse to the index.html file, I am getting this error in the Chrome Dev Console:


I know most of you reading this will probably tell me to go learn Java.  But this is not java code problem.  
Most likely it's a problem with the server configuration supporting CGI?

All I'm looking for is a way to save the variable so a subsequent client user can browse to page on apache-tomcat server and read the same variable.

Whether the way is to use CGI or some other method, I'm open to suggestions.

Let me know if you need any other detaails.

Thanks and I appreciate all responses.

Ray
4 years ago

I am just experimenting and want to play with Apache-Tomcat and CGI.

However I am a java newbee.  Every example/tutorial I see about CGI
says to rename a file servlets-cgi-renameto servlets-cgi.jar  but they don't
say how to use this file?

Any pointers out there to help me learn how to do apache-tomcat CGI?

Thanks.
4 years ago

Paul Clapham wrote:

Ray Jender wrote:Your suggestion goes totally opposite of what I am trying to accomplish.  I don't mind several learning curves.  I just need to learn what I need to do, not program a space launch.....



Oh, sorry. Your original post said you were interested in streaming live video. My mistake was assuming that was your goal. Sorry about that.



I can stream live video already.  I just want to modify how it's being done. I am trying the simple HelloServlet example at https://www.ntu.edu.sg/home/ehchua/programming/java/JavaServlets.html as suggested.

Having problems getting it to run.   Seems that the app I'm running  does not quite follow what I am reading in the various examples and tutorials.  For instance, it is not using port 8080, as some examples call for.
And the file directory structure us not the same as the examples or tutorials.   I'lll keep digging at it until I can no longer take the frustration and then call for help!

Thanks for your help.

Ray

Salil Wadnerkar wrote:I suggest that since you are not familiar with how java servlets work, you can forget about this task for now, and just get "hello world" servlet working. This will introduce you to servlet mapping, and writing simple servlet that handles GET request from browser. Then you can develop a simple program where you submit your name via POST request, and the server responds back with "Hello, <your name>". Once you have these basic pieces working, you can easily finish your task.



Where can I find this "Hello World" servlet?

Paul Clapham wrote:If I understand it right, you have to create this random string exactly once, and then you can start broadcasting.

If that's the case then I would suggest this simpler process:

1. Create the random string.

2. Write it on a piece of paper.

3. Find the place in the application's source code where the user will be looking for the random string.

4. Modify that by hard-coding the random string there.

Right now you're setting yourself up for several learning curves. I'm suggesting you look for opportunities not to go up those curves. There's a recent buzz phrase in programming: Do the simplest thing that can possibly work.



Your suggestion goes totally opposite of what I am trying to accomplish.  I don't mind several learning curves.  I just need to learn what I need to do, not program a space launch.....

Paul Clapham wrote:

Ray Jender wrote:Currently I am playing around with an evaluation copy of a Webrtc media server called antmedia.



So I guess this means that you don't have access to the web app and can't make changes to it?

Is this random value supposed to affect how the web app works?



So I'll define the "broadcaster" as the owner of the app and the live video streamer.
The viewer is anyone who wants to view the broadcast.

I do have access to the source code for the app.  And currently, the broadcaster  has to either accept a default value for the streamID  that he is presented with,
or select his own value.  Then click a "Start Broadcasting" button.  Then, the broadcaster has to manually send this value to whoever wants to view the video broadcast.  

What I am doing is trying to make this process more automatic. So the app user gets the random value and saves it to the database.  Subsequently the viewer browses to another page,
which accesses the database and retrieves the same random value for the streamID and begins viewing the live stream.

I can get as far as generating the random value and assigning it to the broadcaster streamID,  but am stuck at saving it out to the database and on the other side, a viewer
retrieving it to view the broadcast.  Initially I thought an AJAX call to a php would do it, but the app Apache-Tomcat does not support php.

Here is a little more detail:

* Ubuntu 18.04.1 Server.
* Tomcat Version : Apache Tomcat/8.5.38
* Servlet Specification Version : 3.1
* JSP version : 2.3

java -version
openjdk version "11.0.3" 2019-04-16
OpenJDK Runtime Environment (build 11.0.3+7-Ubuntu-1ubuntu218.04.1)
OpenJDK 64-Bit Server VM (build 11.0.3+7-Ubuntu-1ubuntu218.04.1, mixed mode, sharing)

mysql> select version();
+-------------------------+
| version()               |
+-------------------------+
| 5.7.26-0ubuntu0.18.04.1 |
+-------------------------+
1 row in set (0.01 sec)

So I am playing with an evaluation copy of an Apache-Tomcat server application.

I have installed it on Ubuntu 18.04 and it works as advertised.  Great!

Now I am trying to add a process to get a javascript variable and update a mysql database with it. I need to save a single javascript variable in a database.  This is because a subsequent client needs to be able to read it out of the database.
 
So the app came with an index.html file. The top of the index.html file has the following line:

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>

I have created the database WebRTCApp:

mysql> use WebRTCApp;
mysql> select * from broadcast;
+----+----------+
| id | streamID |
+----+----------+
|  1 | 7xh30n4xp08 |
+----+----------+
1 row in set (0.00 sec)

I am creating a random 11 character variable with javascript that I will use to define the streamID.

So, I thought I could accomplish what I need to do using Ajax and PHP, but the Apache-Tomcat server does not support using PHP.  I guess that leaves me with Java Servlets?
 
I've looked at many examples of java servlet usage but the more I look, the more confused I get.

Can anyone advise on how I can achieve, what appears to be simple task? If you need additional information on this mysterious app, let me know.

However, the issue is strictly how apache-tomcat can store a javascript variable  to mysql.  And subsequently, a client retrieves the variable from the same database.

PS: I am not a programmer or coder per-se, more of a "learn-as-I-go" dabbler,  so show this old man a little compassion!  

Thanks,

Ray

4 years ago

Paul Clapham wrote:

Ray Jender wrote:Maybe I did not articulate my issue very well.   I have an existing Apache Tomcat based application that I am modifying slightly.  In order to do the mod,
I create a random 12 digit number using javascript in the index.html file  and need to store it in a mysql database. That's were AJAX comes in.
Subsequently, a user will need to retrieve it from the DB.    The apache tomcat server does not support PHP so I figured java servlets would do the trick?



Okay. For now I will assume the idea of generating the 12-digit number on the client side is okay. Then you have to have some way of sending it to the server side, where Tomcat runs. Your AJAX code would take care of that by sending a request to this servlet you're planning to write.

Can I also assume that your Tomcat application is already using that database? If so then looking at existing servlets which use the database would be helpful.

Confused as to why you say my code is not a servlet?   All examples I have found use the similar method to access the DB?



Your code doesn't even extend HttpServlet. It's true that if you're going to include code in your Tomcat-based application that you're going to have to use servlets, but if you're looking for examples of how to update a database then don't expect those examples to be examples of servlets.



No.  The tomcat is not using any database.

I need only to save one variable in the server so subsequent clients can access it so I thought the database would be the way to go.  In the future I will add more to the db,  but for now I only need to prove I can save and retrieve the variable.
Perhaps there is an easier way?  The apache-tomcat server does not support php, that's why I am trying java.

I can manually run two different java's, one to save and one to read from the db, but I'm stuck how to run them from the index.html page?