Two Laptop Bag*
The moose likes Servlets and the fly likes can any body solved my problem on RequestDispatcher. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "can any body solved my problem on RequestDispatcher." Watch "can any body solved my problem on RequestDispatcher." New topic
Author

can any body solved my problem on RequestDispatcher.

Chidanand Chauhan
Ranch Hand

Joined: Nov 10, 2005
Posts: 77
I am facing a problem with the error
org.apache.jasper.JasperException: /login.jsp(0,19) quote symbol expected


Please check my code.
I have a java file(Servlet) GuestJsp which is forwarding the ServletRequest to login.jsp.

GuesJsp.java stores in tomcat/webapps/WEB-INF/classes/com/example/ GuestJsp.java

File name: GuestJsp.java


package com.example;

import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class GuestJsp extends HttpServlet {


public void doGet(HttpServletRequest req,
HttpServletResponse res)
throws ServletException, IOException
{

req.setAttribute("message", "Hello, world");

ServletContext app = getServletContext();

RequestDispatcher disp;
disp = app.getRequestDispatcher("/login.jsp");

disp.forward(req, res);
}
}


Login.jsp file stores in tomcat/webapps/Myapplication/login.jsp



Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

org.apache.jasper.JasperException: /login.jsp(0,19) quote symbol expected

Looks like the problem is in your login.jsp, not the servlet.


[klunk]
[ December 01, 2005: Message edited by: Ben Souther ]

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

org.apache.jasper.JasperException: /login.jsp(0,19) quote symbol expected
It looks like you are missing a quote symbol in your JSP, nothing to do with the RequestDispatcher.
Chidanand Chauhan
Ranch Hand

Joined: Nov 10, 2005
Posts: 77
Originally posted by David O'Meara:
org.apache.jasper.JasperException: /login.jsp(0,19) quote symbol expected
It looks like you are missing a quote symbol in your JSP, nothing to do with the RequestDispatcher.


Where is the main error in jsp i am pasting my jsp code please find it out where is the quote symbol expected.

File name :login.jsp


<%@ page language=javascript %>

<head>
<title><%= request.attribute.message %></title>
</head>

<body bgcolor='white'>
<h1><%= request.attribute.message %></h1>
</body>
ramprasad madathil
Ranch Hand

Joined: Jan 24, 2005
Posts: 489

The same issue is being dicussed in this post. Chidanand, seeing that both Ben and Dave are giving you answers here, recommend that you stick to this post and give up on the other one.

cheers,
ram.
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

The other copy is now closed, please keep conversations in a single thread.

<%@ page language=javascript %> should have quotes as in [b]<%@ page language="javascript" %>[/.b]
Chidanand Chauhan
Ranch Hand

Joined: Nov 10, 2005
Posts: 77
Ok i give up the other one and start concentrating on this one.

The thing is that where is the problem in my jsp. which i have already pasted over.
Chidanand Chauhan
Ranch Hand

Joined: Nov 10, 2005
Posts: 77
--------------------------------------------------------------------------------
The other copy is now closed, please keep conversations in a single thread.

<%@ page language=javascript %> should have quotes as in [b]<%@ page language="javascript" %>[/.b]



No the same problem is still there.

Exception

org.apache.jasper.JasperException: /login.jsp(0,0) jsp.error.language.nonjava
Chidanand Chauhan
Ranch Hand

Joined: Nov 10, 2005
Posts: 77
Originally posted by David O'Meara:
The other copy is now closed, please keep conversations in a single thread.

<%@ page language=javascript %> should have quotes as in [b]<%@ page language="javascript" %>[/.b]


After deleting the language="javascript" from the code and run the program now gives the exception


exception

org.apache.jasper.JasperException: Unable to compile class for JSP

An error occurred at line: 3 in the jsp file: /login.jsp

Generated servlet error:
[javac] Compiling 1 source file

C:\Tomcat 4.1\work\Standalone\localhost\RequestDispatcherDemo\login_jsp.java:44: cannot resolve symbol
symbol : variable attribute
location: interface javax.servlet.http.HttpServletRequest
out.print( request.attribute.message );
^



An error occurred at line: 7 in the jsp file: /login.jsp

Generated servlet error:
C:\Tomcat 4.1\work\Standalone\localhost\RequestDispatcherDemo\login_jsp.java:49: cannot resolve symbol
symbol : variable attribute
location: interface javax.servlet.http.HttpServletRequest
out.print( request.attribute.message );
^
2 errors


David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

Yes, but now we're seeing the correct errors

You may be confusing scriptlets and JSTL. In scriptlets there is no request.appribute.message, if there is a "message", you gave to get it from the attribute.

<%=request.getAttribute("message") %>
Chidanand Chauhan
Ranch Hand

Joined: Nov 10, 2005
Posts: 77
Originally posted by David O'Meara:
Yes, but now we're seeing the correct errors

You may be confusing scriptlets and JSTL. In scriptlets there is no request.appribute.message, if there is a "message", you gave to get it from the attribute.

<%=request.getAttribute("message") %>



Yea Atlast i did it. Thanks Thanks Thanks David,Ram and Ben for your effort.
Really you people are great.
Thanks once again
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Excellent.
I'm glad it's working for you.

Now that you've got that under your belt, you may want to stroll over to here for some tips on making Javaranch work better for both you and the people trying to help you.

Thanks and Welcome to Javaranch.
-Ben
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: can any body solved my problem on RequestDispatcher.
 
Similar Threads
RequestDispatcher problem
Interesting problem in Forwarding request dispatcher
RequestDispatcher not throwing IllegalStateException
How to arraylist value pass servlet action to JSP file
servlet cant see getServletContext() from inheritance