Click here to Skip to main content
15,896,478 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello everybody

I have jsp page and i want to pass parameter from this jsp page to sql statement in java class
and display output of statement in anther jsp page.

Thanks
Posted
Updated 11-May-13 4:49am
v2
Comments
Sandeep Mewara 11-May-13 10:50am    
And what have you tried so far? Where are you stuck?

There are many way to do that. But the best approach is using MVC/MVC2(Model-View_Controller) pattern. Lots of tutorial are present in web, read them before start.
 
Share this answer
 
use servlet its fine...
example given below..

Java
import java.io.DataInputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

public class Home1 extends HttpServlet {
	
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        String name;
        String date;
        String time;
        String guest;
        String address;
        String discription;

        name=request.getParameter("name");
        date=request.getParameter("date");
        time=request.getParameter("time");
        guest=request.getParameter("guest");
        address=request.getParameter("address");
        discription=request.getParameter("discription");
        HttpSession session=request.getSession(true);
        System.out.println("all is ok");
        try {
                sys.out.print(name);
                sys.out.print(date);
                sys.out.print(time);
                sys.out.print(guest);
                sys.out.print(address);
                sys.out.print(discription);
            } catch (Exception e) {

                e.printStackTrace();
            }
	}
}
 
Share this answer
 
v3
You can set the attributes in jsp page. when forwarding to the action class, the data will be accessible in action class using getParameter method
 
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