2016-06-27 7 views
-3

あなたは、あなたのニーズのPOJOクラスを作成することができますし、同じようHashMapを作成することができますサーブレット、JSPのログインとregestrationを使用すると、

+0

サーブレットを使用して、データベースなしのjsp ecalipse ideのログインと登録フォームをハッシュマップで作成します.... –

+0

** in ecalipse ** –

+2

あなたの質問は何ですか? – Lexi

答えて

-1

をハッシュマップ使用してデータベースずにサーブレットとJSPを使用してログインし、登録フォームを作成します。フォーム:私は鍵を取ります(文字列、POJOクラス)

//Map Representation: Map<String, List<Person>> personDetails = new HashMap<String, List<Person>>(); 

    class Person{ 
     private String name; 
     //other variables 

     //Setters and getters 
     public void setName(String name){ 
       this.name = name; 
     } 

     public String getName(){ 
       return name; 
     } 
     } 

    public class LoginDetails extends HttpServlet{ 

    Map<String, List<Person>> carDetails = new HashMap<String, List<Person>>(); 

    public void doGet(HttpServletRequest request, 
         HttpServletResponse response) 
       throws ServletException, IOException 
     { 
      String name = request.getParameter("name"); 
      String uname = request.getParameter("uname"); 

      if(name != null && uname != null){ 
       Person p1 = new Person(); 
       p1.setName(name); 
       personDetails.put(uname, p1); //This makes a primary key kind of //relation and makes a virtual database in memory. You can even //retrieve it easily using for loop. 
    //You can do the same for the rest of your logic. 
      } 


     } 

    } 

このようにすると、主キーを持つデータベースのテーブルのような構造になります。お役に立てれば...!!!

関連する問題