ragazzi conoscete qualcuno che offre hosting gratuito con supporto tomcat e mySql
spero che esistano visto che sono entrambi gratuiti , comunque continuo a cercare
![]()
ragazzi conoscete qualcuno che offre hosting gratuito con supporto tomcat e mySql
spero che esistano visto che sono entrambi gratuiti , comunque continuo a cercare
![]()
http://www.myjavaserver.com
Registrazione gratuita, devi solo risolvere un semplice esercizio java.
Pero' non ti danno troppo spazio, visto che e' gratis.
scusa ma non sono molto ferrato con l'inglese ... cosa vuole che ci scrivo in quella funzione?
L'array di stringhe 'config' contiene dei percorsi URI e i nome handler associati. 2 valori consecutivi(a coppie) rappresentano l'URI e il suo handler. La funzione 'getHandler'deve ritornare il corretto handler per uno specifico URI passato come stringa.
L'handler il cui URI "matcha" maggiormente vince se piu' di un URI "matcha". Se nessuno "matcha", ritorna "CeAkxsj" .
Esempio:
String[] config: { "/", "MainServlet", "/nav", "NavigationServlet" }
String requestUri: "/nav/test"
Correct result: "NavigationServlet"
In questo esempio, config contiene il mappaggio ("/" per "MainServlet" e "/nav" per "NavigationServlet").
L'URI in ingresso è"/nav/test.nav", "NavigationServlet" e' la scelta corretta perche' "matcha" maggiormente di "MainServlet".
Provo a postare quello che nel sito è chiamato Master a simple Java programming challenge
Signup Challenge
Master a simple Java programming challenge (STATUS: NOT PASSED)
As the principal engineer of an HTTP web server, you are responsible for implementing the request processing subsystem of the server.
An incoming request for a specific resource, identified by an URI, must be dispatched to the appropriate handler according to the server configuration which maps URIs to request handlers. 'HandlerFactory.getHandler' must be implemented:
public class HandlerFactory
{
public String getHandler(String[] config, String requestUri)
{
}
}
The string array 'config' contains URI patterns and handler names. Two consecutive values form a key-value pair comprised of URI pattern and handler. 'requestUri' represents an incoming request, the URI to match against the configured handlers. 'getHandler' must return the correct handler for a given URI as a string value.
An URI pattern never contains wildcards and represents the start of an URI string, a prefix. Matching must be implemented accordingly. The handler with the longest matching URI pattern wins if more than one pattern matches. If no handler can be found, "eYXxrE" must be returned.
Example input:
String[] config: { "/", "MainServlet", "/nav", "NavigationServlet" }
String requestUri: "/nav/test"
Correct result: "NavigationServlet"
In this example, the configuration contains a mapping of "/" to "MainServlet" and "/nav" to "NavigationServlet". In the case of an incoming URI "/nav/test.nav", "NavigationServlet" is the correct choice because its pattern is longer than that of "MainServlet".
e poi da da riempire questo metodo
codice:public class HandlerFactory { public String getHandler(String[] config, String requestUri) { } }
Un aiutino a compilare questo metodo![]()
Sopra ti ho tradotto il testo dell'esercizio.
In parole povere:
hai una stringa requestUri e un array di coppie(URI, handler)
imposti una variabile index int a -1
scorri l'array di due in due (in modo da valutare solo gli URI e non gli handler) con un ciclo con indice i
ad ogni iterazione
1) controlli se requestUri inizia per la sottostringa config[i]
2) se inizia confronti se config[i].length>config[index.lenght] (naturalmente quando index e' != -1)
3) se la condizione e' verificata, salvi il valore di i dentro index
alla fine se index e' uguale a -1 non hai trovato niente, altrimenti restituisci EDIT config[index+1]
grazie per l'immenso consiglio che hai postato mi ci vorra' un po di tempo prima di scrverlo
appena pooso aggiorno questo posto
adesso se manga![]()