Questions tagged [requestdispatcher]

The request dispatcher is used for receiving requests from the client and sending them to any resource (such as a servlet, HTML file, or JSP file) on the server.

The request dispatcher is used for receiving requests from the client and sending them to any resource (such as a servlet, HTML file, or JSP file) on the server. The most common approach is forward or include resource to the client.

The servlet container creates the RequestDispatcher object, which is used as a wrapper around a server resource located at a particular path or given by a particular name.

See RequestDispatcher API docs for details.

213 questions
0
votes
1 answer

JavaScript (in jsp) receive String from Java

Good Morning: I am having several problems trying to receive a String from Java to JSP (Javascript inside). Java File String var = "Hello World!"; JavaScript (inside the JSP): window.onload = function() { loadData(); }; function…
DeathGun
  • 79
  • 2
  • 10
0
votes
1 answer

HttpSession vs RequestDispatcher

Please let me help to understand when to use session instead of RequestDispatcher. So far I have seen I can pass data from servlet to servlet and jsp forwarding the request and It can pretty much distinguish two different request. So when and why…
0
votes
2 answers

response.sendRedirect not directing to jsp from servlet when made from a jQuery post call

Before posting this question I cross referenced previous questions on this and other communities blog but my problem remains. Problem I am not able to redirect my servlet to a new jsp from the doPost() method in the servlet. I called the doPost…
raikumardipak
  • 1,461
  • 2
  • 29
  • 49
0
votes
0 answers

Forward request from servlet1 to servlet2 and get the output from servlet2 in servlet1 to filter it out further

I have been trying to forward a request from servlet1 to servlet2, which I was able to do successfully using RequestDispatcher.forward(request, response), but this way it prints the output from servlet2. I want to get output from servlet2 in…
Purva
  • 1
  • 1
0
votes
1 answer

404 - Not Found Error RequestDispatcher jsp forward

I am trying to forward a Servlet to a JSP and I get this error when I click on the button that calls the doGet() that forwards into the JSP Type Status Report Message /servlet/crossfit/WOD Description The origin server did not find a current…
0
votes
1 answer

how to send multiple values(attributes) from one servlet to another servlet or JSP in J2EE

I want to send multiple data values that has been retrieved from database to another servlet or jsp. Here is my code PreparedStatement st= conn.prepareStatement("select name from users where uname=? and pword=?"); st.setString(1, uname); …
0
votes
0 answers

What is diiference between Root Directory and Parent Directory in Jsp?

Using request dispatcher i forwarded the request to new Jsp page. The stylesheet is not loading when i use the following the lines < link rel="stylesheet" type="text/css" href="../css/style.css"> But Stylesheet is loading when i replace this line…
Chandru Jc
  • 105
  • 10
0
votes
1 answer

NullPointerException when `RequestDispatcher` is fired

I am using Retrofit to connect to my REST API. Please check the below code import com.google.gson.Gson; import com.google.gson.GsonBuilder; import java.io.IOException; import java.io.PrintWriter; import java.util.Date; import…
PeakGen
  • 21,894
  • 86
  • 261
  • 463
0
votes
1 answer

request.forward(request, response) get NullPointerException Error

I get NullPOinterException Error when i run my processList.java servlet..please help My Project explorer (I don't have enough reputation to show it directly...please click the link to see the image) my project explorer processList.java servlet***I…
user5244370
0
votes
1 answer

Where and how do doGet,doPost and service in servlets work?

I have made a project in where three string parameters entered by user are sent to a servlet named controller. There I have used RequestDispatcher to forward those three parameters to a JSP page and print them. I have did something and made it work…
rsanath
  • 1,154
  • 2
  • 15
  • 24
0
votes
1 answer

How to register multiple servlets in WebApplicationInitializer programatically?

I wrote the below class to register multiple servlets programmatically but it is not working can any one help me on this. public class appIntializer implements WebApplicationInitializer { @Override public void onStartup(ServletContext…
Gowtham Murugesan
  • 407
  • 2
  • 6
  • 17
0
votes
1 answer

How to get dispatcher servlet name in Spring controller

Below is my web.xml DispatcherName org.springframework.web.servlet.DispatcherServlet contextConfigLocation
0
votes
2 answers

unable to hide filename in the URL using JSP

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: …
purplewind
  • 331
  • 10
  • 26
0
votes
2 answers

RequestDispatcher not redirecting in java servlet to JSP

I'm trying to redirect to another page from my servlet where string value is null. When I run the code it stays on the same page instead of redirecting to my error page. Here is my code: public void doPost(HttpServletRequest request,…
Gee
  • 155
  • 2
  • 6
  • 21
0
votes
1 answer

Request Dispatcher skipping the url after question mark

Iam trying to call a request dispatcher from a servlet with the following url but the request dispatcher is not properly forming the url Iam doing it in the following way RequestDispatcher rd1 =…