- š Hi, Iām @HtutLin-Htet
- š Iām interested in ...
- š± Iām currently learning ...
- šļø Iām looking to collaborate on ...
- š« How to reach me ...
- š Pronouns: ...
- ā” Fun fact: ...
HttpSession session=request.getSession(true); ArrayListpreviousItems=(ArrayList)session.getAttribute("previousItems"); if(previousItems==null) { previousItems=new ArrayList(); session.setAttribute("previousItems", previousItems); } String newItem=request.getParameter("newItem"); if((newItem!=null)&&!newItem.trim().equals(" ")) previousItems.add(newItem); response.setContentType("text/html"); PrintWriter out=response.getWriter(); String title="Item Purchased"; out.println("<body bgcolor="#FDF5E6">\n"+"
"); if(previousItems.size()==0) { out.println("No Items"); }else { out.println("- ");
for(String item:previousItems) {
out.println("
- "+item+" "); } out.println("
<display-name>SessionEg1</display-name>
Student Registration
<title>Insert title here</title>Name: | |
Gender: | Male Female |
NRC: | |
Father Name: | |
Address: | <textarea name="txtAdd"></textarea> |
Phone: | |
HttpSession session=request.getSession(); String s=(String)session.getAttribute("id"); int n=0; if(s==null || s.length()==0) n=1; else n=Integer.parseInt(s); session.setAttribute("id", String.valueOf(n+1)); String name=request.getParameter("txtName"); String gender=request.getParameter("rdoGender"); String nrc=request.getParameter("txtNRC"); String fname=request.getParameter("txtFname"); String add=request.getParameter("txtAdd"); String phone=request.getParameter("txtPh"); PrintWriter pw=response.getWriter(); pw.println("Student ID: UCS-"+n); pw.println("Name: "+name); pw.println("Gender: "+gender); pw.println("NRC:"+nrc); pw.println("Father: "+fname); pw.println("Address:"+add); pw.println("Phone:"+phone);
SessionEg2 StudentServlet sessionEg.StudentServlet StudentServlet /StudentServlet Student.html StudentServlet.java