0

I am developing a web application and right now I am trying to "hide" the file name in the URL.

It is currently like that:

/localhost/test/faculty_searchstudents.jsp

I want to hide the file name. I have tried using requestdispatcher like that:

  while (resultSet.next()) {
      String first_name = resultSet.getString("firstname");
      String last_name = resultSet.getString("lastname");
      String email = resultSet.getString("email");

      Object[] student = {first_name,last_name,email};
      studentList.add(student);
  }
  session.setAttribute("studentObject",studentList);
  RequestDispatcher dispatcher = getRequestDispatcher("faculty_searchstudents.jsp");
  dispatcher.forward(request,response); 

However when I run this code, it says that

"The method getRequestDispatcher(String) is undefined ".

I already import it at the top of the file like this :

  <%@page import = "javax.servlet.*" %>

How do I hide the filename in the URL?

Chirag Parmar
  • 833
  • 11
  • 26
purplewind
  • 331
  • 10
  • 26
  • you can do as request.getRequestDispatcher("faculty_searchstudents.jsp") – Vasu Nov 15 '16 at 10:04
  • Hi, i have tried that, it kinda works but now it displays a blank webpage; My session.getAttribute("studentObject",studentList) is not displayed :( – purplewind Nov 15 '16 at 10:09

2 Answers2

1

Use this

 RequestDispatcher dispatcher =getServletContext().getRequestDispatcher("faculty_searchstudents.jsp");
Sarthak Srivastava
  • 1,490
  • 3
  • 15
  • 33
0

You can use this :

RequestDispatcher rd = request.getRequestDispatcher("faculty_searchstudents.jsp");
Sachin Parse
  • 1,269
  • 11
  • 12