DIGIT-ARC read-only archive · snapshot: July 23, 2026

Help: passing javascript variable to other html

1 post · originally from https://geek.digit.in/community/threads/help-passing-javascript-variable-to-other-html.138830/

speedyguy
speedyguy Original post #1
Apr 3, 2011 at 7:37 PM
Consider the following code in jsp where im validating a login and password:::

-----------------------------------------------------------------------
<body bgcolor="grey">
<h1> WELCOME TO XYZ</h1>




<%
String usr2=request.getParameter("username");
String pwd2=request.getParameter("pwd");
String sel2=request.getParameter("sel");

Class.forName("com.ibm.db2.jcc.DB2Driver").newInstance();
Connection con=DriverManager.getConnection("jdbc:db2://localhost:50000/DBName","username","password");
String sql="SELECT id from login where id='"+usr2+"' and pwd='"+pwd2+"' and typ='"+sel2+"'";
Statement st=con.createStatement();
ResultSet rs= st.executeQuery(sql);
String str;
if (rs.next())
{
str=rs.getString(1);
out.println("Succesfully Logged in as " + str);
%>
<a href="home.html"> Click here to continue...</a>
<%
}
else
out.println("Invalid User ID/Password. Please go back and try again.");

rs.close();
rs=null;
st.close();
st=null;
con.close();

%>



</body>

--------------------------------------------------------------------------

Now upon successful validation i need to goto to next html page which depends on login type and id. so i need some parameters like "usr2" and "sel2" to pass on 2 next page (using href as given above) and depending on it different pages would open. Can anyone tell me how do i do that?
Sorry, newbie to scripting and html..

Thanks.

Enjoy~!