Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
1844 connectés 

  FORUM HardWare.fr
  Programmation
  Algo

  [JSP] Problème de contexte

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

[JSP] Problème de contexte

n°1425198
PETOZAK
Posté le 14-08-2006 à 09:28:57  profilanswer
 

Bonjour,
 
J'utilise une servlet d'authentification au demarage de mon application :
 
 

Code :
  1. public class ServletAuthentication extends HttpServlet {
  2. static public final int ERREUR_LOGIN=0;
  3. static public final short ERREUR_SESAME=1;
  4. /**
  5.  * x x
  6.  */
  7. private static final long serialVersionUID = 1L;
  8. // init
  9. public void init() {
  10. }
  11. // GET
  12. public void doGet(HttpServletRequest request, HttpServletResponse response)
  13.   throws IOException, ServletException {
  14.  String login = request.getParameter("UserLogin" );
  15.  String pwd = request.getParameter("UserPassword" );
  16.  int id_presta = -1;
  17.  System.out.println("LOGIN = " + login);
  18.  System.out.println("PWD = " + pwd);
  19.  if (login != null) {
  20.   //Connexion a MySQL pour savoir si le contractor existe
  21.   Connexion objcon = new Connexion();
  22.   Statement stmt = objcon.getStmt();
  23.   String query = "SELECT id_presta  from prestataires where CONCAT(prenom_presta,'.',nom_presta) like '%"
  24.     + login + "%' and  id_presta IS NOT NULL ";
  25.   System.out.println(query);
  26.   try {
  27.    ResultSet rs = stmt.executeQuery(query);
  28.    if (rs.next()) {
  29.     id_presta = rs.getInt("id_presta" );
  30.     System.out.println("idpresta: " + id_presta);
  31.    }
  32.   } catch (Exception e) {
  33.    e.printStackTrace();
  34.   }
  35.   if (id_presta != -1) {
  36.    request.setAttribute("id_presta", Integer.valueOf(id_presta));
  37.    request.getSession().setAttribute("id_presta", Integer.valueOf(id_presta));
  38.    getServletContext().getRequestDispatcher("/jsp/Planning.jsp" )
  39.      .forward(request, response);
  40.   } else {
  41.    //Erreur de Login
  42.    getServletContext().getRequestDispatcher("/jsp/index.jsp?error="+ERREUR_LOGIN)
  43.      .forward(request, response);
  44.   }
  45.  }
  46. }
  47. // POST
  48. public void doPost(HttpServletRequest request, HttpServletResponse response)
  49.   throws IOException, ServletException {
  50.  // on passe la main au GET
  51.  doGet(request, response);
  52. }
  53. }


 
 
Mon repertoire contenant tout le côté vue se trouve dans le repertoire JSP. (Javascript , XML , CSS...)
Le problème c'est que l'on redirigeant vers le repertoire JSP , le contexte semble rester sur :
http://127.0.0.1:7979/PrestaSelfService/ServletAuthentication
 
Au lieu de http://127.0.0.1:7979/PrestaSelfService//jsp/Planning.jsp
 
Par consequent le code JS et CSS est introuvable :(...Bien sur je peux remplacer :
 
<link rel="stylesheet" type="text/css" href="css/standard.css"> par
<link rel="stylesheet" type="text/css" href="jsp/css/standard.css">
 
Mais est ce bein joli? :(

mood
Publicité
Posté le 14-08-2006 à 09:28:57  profilanswer
 

n°1425199
jbourdello​n
Posté le 14-08-2006 à 09:37:36  profilanswer
 

Citation :

getServletContext().getRequestDispatcher("../jsp/Planning.jsp" ).forward(request, response);


C'est pas plutot ca ?  
 

Citation :

http://127.0.0.1:7979/PrestaSelfService//jsp/Planning.jsp


Faute de frappe ? parce qu'autrement ca marchera pas...

n°1425201
PETOZAK
Posté le 14-08-2006 à 09:39:21  profilanswer
 

faute de frappe :)


Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Programmation
  Algo

  [JSP] Problème de contexte

 

Sujets relatifs
Problème avec nombre d'enregistrements dans une tableProblème de compatibilité: Sessions espace membre + Quiz Self Page!
[C]Problème d'inclusions imbriquées[LINUX] Probleme de gcc sous le terminal
Problème de liens survoléProblème avec Ganttproject ...
Problème UTF8 +scriptproblème avec NVU
Probléme de ???Probleme de marge
Plus de sujets relatifs à : [JSP] Problème de contexte


Copyright © 1997-2022 Hardware.fr SARL (Signaler un contenu illicite / Données personnelles) / Groupe LDLC / Shop HFR