naveenSir i 3 jsp pages...first one home.jsp form name="form" class="sf-menu ul" method="post" action="check.jsp"> <table border="10"> <tr><td background="orange">Username:</td><td><input type="text" name="username"></td></tr> <tr><td>Password:</td><td><input type="password" name="password"></td></tr> <tr><td></td><td><input type="submit" value="Submit"></td></tr> </table> <a href="register.jsp"><img alt="doit" src="button_jointoday.png" height="60",width="60"></a> <marquee class="c">this is naveen website</marquee> </form> </body> </html> then **check.jsp" <%@page import="java.sql.*" import ="
javax.servlet.RequestDispatcher;
"%>
<% String username=request.getParameter("username");
String password=request.getParameter("password");
Class.forName("com.mysql.jdbc.Driver");
Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/naveen","root","naveen");
Statement st=con.createStatement();
ResultSet rs=st.executeQuery("select * from myaccount where username='"+username+"' and password='"+password+"'");
int count=0;
while(rs.next())
{
count++;
}
if(count>0)
{
response.sendRedirect("detail.jsp");
}
else
{
response.sendRedirect("home.jsp?msg=Invalid Username or Password");
}
%>
and third one is details.jsp <%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8" import ="java.sql.*" import = "java.io.*" import="
javax.servlet.RequestDispatcher;
"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<%
String username=request.getParameter("username");
String password=request.getParameter("password");
PrintWriter pw = response.getWriter();
pw.println(username);
pw.println(password);
now the problem is if i enter username and password the values are going to check.jsp due to action command ...but the values i entered is not able to get my details.jsp.. in check.jsp itself i can able to print my username and password but i want to display in third page only ple help me out... ple how can i get values from firstjsppage to thirdjsp but action is mentioned for second jsp...any method is there any idea ple help me..both are in same package View Answers
April 3, 2012 at 5:40 PM You can use request.setAttribute()or session.setAttribute(). In check.jsp: <%@page import="java.sql.*" %>
<%@import ="javax.servlet.RequestDispatcher"%>
<% String username=request.getParameter("username");
String password=request.getParameter("password");
Class.forName("com.mysql.jdbc.Driver");
Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/naveen","root","naveen");
Statement st=con.createStatement();
ResultSet rs=st.executeQuery("select * from myaccount where username='"+username+"' and password='"+password+"'");
int count=0;
while(rs.next()){
count++;
}
if(count>0){
request.setAttribute("user",username);
request.setAttribute("pass",password);
RequestDispatcher dispatcher = request.getRequestDispatcher("detail.jsp");
if (dispatcher != null){
dispatcher.forward(request, response);
}
}
else
{
response.sendRedirect("home.jsp?msg=Invalid Username or Password");
}
%>
In details.jsp: <%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8" import ="java.sql.*" import = "java.io.*" import="javax.servlet.RequestDispatcher;"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<%
String username=request.getAttribute("user");
String password=request.getParameter("pass");
PrintWriter pw = response.getWriter();
pw.println(username);
pw.println(password);
%> For more information, visit the following links: Related Tutorials/Questions & Answers: naveen ;</a> <marquee class="c">this is naveen website</marquee> <...","naveen"); Statement st=con.createStatement(); ResultSet rs...","naveen"); Statement st=con.createStatement(); ResultSet rs Advertisements ModuleNotFoundError: No module named 'outlier-naveen' ModuleNotFoundError: No module named 'outlier-naveen' Hi, My... named 'outlier-naveen' How to remove the ModuleNotFoundError: No module named 'outlier-naveen' error? Thanks Hi, In your python ModuleNotFoundError: No module named 'topsis-naveen' ModuleNotFoundError: No module named 'topsis-naveen' Hi, My... 'topsis-naveen' How to remove the ModuleNotFoundError: No module named 'topsis-naveen' error? Thanks Hi, In your python Java Documentum - Java Magazine Java Documentum Hi All, Can anybody explain and provide good examples about JavaDocumentum. How can i start learning Documentum. Please help me.... Regards, Naveen Hi friend, For read Difference in size of .java & its respective .class file . Could anyone suggest the reason. Thanks in advance. ~Naveen java compilation error - Development process java compilation error i have a requirement in my prog where i need to create multiple references while looping is going on for example i have a for loop like for(int i=0;i<5;i++) { String s=new String("naveen"); } now problem in sending data from one ip to another ip in JAVA problem in sending data from one ip to another ip in JAVA Hi guys . this is naveen kumar...i need a help. i want to connect one ip to another ip (like ping),after that i want send the data with my system(Ip) to another ip is it necessary to have depth knowledge on servlets jsp and jdbc to learn java frameworks is it necessary to have depth knowledge on servlets jsp and jdbc to learn java frameworks Hi.. My name is naveen..Im planning to learn java frame works i.e., struts,hibernate and spring.. i dont have that much depth or practical java - Java Beginners ,'Naveen',12345,'[email protected]') insert proj values(1002,'Naveen',12345,'[email protected]') insert proj values(1003,'Naveen',12345,'[email protected]') insert proj values(1004,'Naveen',12345,'[email protected]') insert proj values file share to particular user =DriverManager.getConnection("jdbc:odbc:naveen","naveen","naveen"); ResultSet rs = null; Statement...("sun.jdbc.odbc.JdbcOdbcDriver"); con=DriverManager.getConnection("jdbc:odbc:naveen","naveen","naveen"); ResultSet rs = null; Statement st=null; st=con.createStatement Updating rows who has same id with different values for each row from java program (having sid 1) with "naveen" as value for sname column.And second row(having sid 1 To display suggestions in a text box - Ajax . Thanks and Regards, Naveen Hi friend, This can be done by using... AJAX!"); return; } var url="gethint.jsp"; url=url+"?q="+str; url=url.... Please correct me, if i did any mistake. Thanks and Regards, Naveen The Beginners Guide to JAXB part 3 Oriented Architecture Frameworks"); article.setAuthor("Naveen Balani"... Architecture Frameworks</title> <author>Naveen Balani</author> < Questions by Category
|