Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

request can not be resolved

 
Nirvikalp Rao
Greenhorn
Posts: 27
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am calling a "view.jsp" from a servlet.My doPost method which is calling "view.jsp" is here

the "view.jsp" goes here:

but i am getting the error as follows:

the target jsp is in the root directory of the application,where WEB-INF folder is also placed.
 
Shankar Tanikella
Ranch Hand
Posts: 329
Eclipse IDE Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Rao,
Since you are creating a new JSP, stop using scriplets (Everything would work fine)

Nirvikalp Rao wrote:req cannot be resolved
Did you edit the exception while posting? The exception should show "request cannot be resolved" instead of 'req'. If you didn't edit clean your server cache and try the same again.
 
Anurag Verma
Ranch Hand
Posts: 167
Hibernate Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
remove the html & body tags. it should work directly.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64629
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Anurag Verma wrote:remove the html & body tags. it should work directly.

Huh? How will that resolve the problem? Please don't suggest things that don't address the problem.

 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64629
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is most likely that the path to the JSP is wrong. Please include the original error message (not your misspelling of it) and the location of the target JSP within the web app.
 
Karn Kumar
Ranch Hand
Posts: 153
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your Code seems correct, also the file location seems correct as it reaches the line where the request has been written . Just try Shankar's advice. Delete Work forlder and clean & build the project and restart it. Also there is minimal possibility that your jars are incorrect.
 
Nirvikalp Rao
Greenhorn
Posts: 27
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:It is most likely that the path to the JSP is wrong. Please include the original error message (not your misspelling of it) and the location of the target JSP within the web app.

The target Jsp "view.jsp" is in the root directory of the web application.And if i am just printing a simple message in jsp(instead of calling getAttribute() method on request object),it is working fine.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64629
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
RequestDispatcher disp=request.getRequestDispatcher("/view.jsp");

And the fact that you have Java code in your JSP is very disturbing.
 
Nirvikalp Rao
Greenhorn
Posts: 27
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote: RequestDispatcher disp=request.getRequestDispatcher("/view.jsp")

Still getting the same error.
 
Omkar chary
Greenhorn
Posts: 11
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your code is absolutely right!
but make sure
you used the HttpServletRequest reference variable named as "request".
because in JSP used to allow the default reference variable name must be named in your servlet doGet/doPost(HttpServletRequest request, .......)
in your jsp!
<%
It must be used by the name as.....

request.getAttribute();
%>

Firstly i got the same error!
It solved!
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64629
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Omkar onky wrote:
but make sure
you used the HttpServletRequest reference variable named as "request".
because in JSP used to allow the default reference variable name must be named in your servlet doGet/doPost(HttpServletRequest request, .......)
in your jsp!

No. What the variable is named in the servlet has absolutely nothing at all to do with accessing the built-in scripting variable in the JSP.
 
G krishna kumar
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
List l=bm.getBrand(s); /// here in this line

my question did you compile your servlet.
and how you are able to assign a string to a List.
you have an
: incompatible types
found : java.lang.String
required: java.util.List

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic