PDA

View Full Version : Si può integrare Tomcat con Javascript?


Scoperchiatore
11-05-2004, 10:55
Domanda da un milione di dollari: vi spiego meglio.

Sto allargando un'applicazione fatta in htm+javascript che si collega a un DB (Tamino) e fa le semplici operazioni crud (ricerca, modifica,....)

Io ho deciso di fare la mia parte in JSP usando Tomcat come web-server.

L'applicazione deve girare in remoto.

Ora mi si è posto questo problema. Il web server, quando sto eseguendo l'applicazione in remoto, e gli chiedo di andare su una pagina "vecchia" fatta in javascript, fa quello che non deve fare: RIMANDA al client il codice html della pagina che ho richiesto e ESEGUE GLI SCRIPT PER LA CONNESSIONE AL DB SUL CLIENT, dove logicamente non c'è nessun DB! :cry: :cry:

Quindi, se non risolvo questo problema devo
1) o rifare l'applicazione in JSP (e non ho tempo)
2) fare in javascript quello che devo fare ossia

Autenticare utenti e amministratori
Inserire un profilo dinamico per utenti
Implementare con un algoritmo di Intelligenza Artificiale una ricerca migliorata


Mi troverei troppo scomodo a non usare uno strumento più potente di javascript! :muro:

Scoperchiatore
11-05-2004, 11:11
Mi rispondo da solo :sob:


Is JavaScript supported as a JSP scripting language under Tomcat?


In short, no.

Putting things very very simply, Tomcat is essentially a Java Servlet Compiler, taking the .jsp file you write and translating it to a java servlet that runs in the background.

Java, according to the Apache development group that wrote Tomcat (known as the Jakarta group) conforms solely to the JSP 1.2 / Servlet 1.1 specification by Sun Microsystems. When they wrote Tomcat, they only had in mind to use Java as the "scripting language". In fact, Tomcat is built with java, thereby heavily integrating the technology.

I hope you know this, but JavaScript and Java are two entirely different languages (some things are similar, but most are not). The two technologies are by no means interchangeable, and this intuitively applies to Tomcat. To the best of my knowledge the Apache Tomcat developmental teams have no current plans to integrate other scripting technologies into the software (for many reasons, of which I won't go into here for brevity).

However, you may include JavaScript within the .jsp file (not within jsp interpretable <% %> tags), and it will be output to the client browser for interpretation just like in an HTML page. The key here is to realize that it has no interaction/functionlity with the server before it is sent to the client.

:sob: Esattamente il contrario di quello che succede qua! :muro: