Click here to Skip to main content
15,887,596 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
***************This is the Index page where Iam giving the Data**********************
ASP.NET
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<jsp:useBean id="demo" class="demo.Demo" scope="session"/>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<h1>Welcome !!!</h1>
<form id="myform" name="myform" method="post" action="Basic.jsp">--> 
  <input type="text"  name="user" />
    <input type="text"   name="password" />    
    <input type="submit" value="go" onclick="Basic.jsp'" />
    </form>

</body>
</html>


**************************This Is the Basic.Jsp page From where I am sending The data to Java Class,And want That data to be get from java class and printed in this page*****

ASP.NET
 <%@ page import="demo.Demo,java.io.* ,javax.xml.parsers.*,javax.xml.transform.*, javax.xml.transform.dom.*,javax.xml.transform.stream.*,javax.xml.*,org.w3c.dom.*,demo.Demo"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
   
    
  
   
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<jsp:useBean id="demo" class="demo.Demo" scope="session"/> 

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<h1>hiiiii</h1>
 <%String name = request.getParameter("user"); 
 String pass =request.getParameter("password");
 demo.Demo fb = new demo.Demo(); 
 fb.setUser(name);
 fb.setPassword(pass);
 %>
 Name:<%fb.getUser(); %> 
 password:<%fb.getPassword(); %>  
     
</body>
</html>

****************************Demo.java class*******************************************
C#
package demo;

public class Demo {
	
String user="";
String password="";
public void setUser(String users){
	this.user=users;
	System.out.println(user);
}
public void setPassword(String pass){
	this.password=pass;
	System.out. println (password);
}
public String getUser(){
	return  this. password;
}
public String getPassword(){
	return this.password;
}

}
Posted
Updated 15-Jan-18 10:33am

1 solution

Please use this modified code as a solution :

1). For index page
===================================
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"

    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<jsp:useBean id="demo" class="demo.Demo" scope="session"/>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<h1>Welcome !!!</h1>
<form id="myform" name="myform" method="post" action="Basic.jsp">
  <input type="text"  name="user" />
    <input type="text"   name="password" />    
    <input type="submit" value="go" onclick="Basic.jsp'" />
    </form>

</body>
</html>


========================================


2). For Basic.jsp

========================================
 <%@ page import="demo.Demo,java.io.* ,javax.xml.parsers.*,javax.xml.transform.*, javax.xml.transform.dom.*,javax.xml.transform.stream.*,javax.xml.*,org.w3c.dom.*,demo.Demo"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"

    pageEncoding="ISO-8859-1"%>
   
    
  
   
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<jsp:useBean id="demo" class="demo.Demo" scope="session"/> 

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<h1>hiiiii</h1>
 <%
 String name = request.getParameter("user"); 
 String pass =request.getParameter("password");
 Demo fb = new Demo(); 
 fb.setUser(name);
 fb.setPassword(pass);
 %>
 Name:<%out.print(fb.getUser());%> 
 password:<% out.print(fb.getPassword()); %>  
     
</body>
</html>


===============================

3). For Demo class :
===============================
package demo;

public class Demo {
	
String user="";
String password="";
public void setUser(String users){
	this.user=users;
	System.out.println(user);
}
public void setPassword(String pass){
	this.password=pass;
	System.out. println (password);
}
public String getUser(){
	return  this. user;
}
public String getPassword(){
	return this.password;
}

}


================
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900