This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Servlets and the fly likes calling jsp from servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Servlets
Reply locked New topic
Author

calling jsp from servlet

ankur tyagi
Ranch Hand

Joined: Apr 01, 2009
Posts: 49
i was trying the example given in ch 3 of head first for jsp and servlets...
the application was working fine until the last step where jsp is used to show the result page..
the following exception occurs..
type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: XML parsing error on file /WEB-INF/web.xml: (line 6, col 21)
org.apache.jasper.compiler.JspConfig.processWebDotXml(JspConfig.java:185)
org.apache.jasper.compiler.JspConfig.init(JspConfig.java:198)
org.apache.jasper.compiler.JspConfig.findJspProperty(JspConfig.java:250)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:113)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:317)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:298)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:286)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:564)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:302)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
BeerSelect.doPost(BeerSelect.java:22)
javax.servlet.http.HttpServlet.service(HttpServlet.java:647)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729).......


this are my codes
BeerSelect.java

BeerExpert.java

result.jsp

web.xml

directory structure in tomcat is like this
webapps
|
beerv1
|-form.html , result.jsp
WEB-INF
|-web.xml
classes
|- BeerSelect.class, BeerExpert.class
James Tharakan
Ranch Hand

Joined: Aug 29, 2008
Posts: 580

List styles = (List)requst.getAttribut("styles");


Please correct the TWO spelling mistakes... !!!


SCJP 6
Why to worry about things in which we dont have control, Why to worry about things in which we have control ! !
Pushkar Choudhary
Rancher

Joined: May 21, 2006
Posts: 425

Read the first line of the error message carefully.
ankur tyagi wrote:org.apache.jasper.JasperException: XML parsing error on file /WEB-INF/web.xml: (line 6, col 21)


Are you sure the following line is correct in your web.xml?
ankur tyagi wrote:

Also, correct the spelling mistakes pointed out by James.
ankur tyagi
Ranch Hand

Joined: Apr 01, 2009
Posts: 49
about the xml file ..
this line was working fine before...
and even after correcting the spelling mistakes ,the error is still there..
Pushkar Choudhary
Rancher

Joined: May 21, 2006
Posts: 425

ankur tyagi wrote:about the xml file ..
this line was working fine before...

After checking that it was working, what changes did you make that made the server go mad?
James Tharakan
Ranch Hand

Joined: Aug 29, 2008
Posts: 580

What is the current error message??
Hope you re-deployed server
ankur tyagi
Ranch Hand

Joined: Apr 01, 2009
Posts: 49
no changes in the xml file only the changes in the BeerSelect.java file as you can see in
the code to call the result .jsp file to make the output page..
previously the servelt itself was showing the output ...


the error remains the same..
yes, restarted the server if that is re-deployment means..
James Tharakan
Ranch Hand

Joined: Aug 29, 2008
Posts: 580

ankur tyagi wrote:no changes in the xml file only the changes in the BeerSelect.java file


Hope you changed the result.jsp as i mentioned in my first post.
ankur tyagi
Ranch Hand

Joined: Apr 01, 2009
Posts: 49
ankur tyagi wrote:about the xml file ..
this line was working fine before...
and even after correcting the spelling mistakes ,the error is still there..

i told you that before..
yes i corrected the spell mistakes..
Pushkar Choudhary
Rancher

Joined: May 21, 2006
Posts: 425

Just compared your code with the book. The line in web.xml mentioned in my first post here is indeed different from how it is in the book. Can you check again?
ankur tyagi
Ranch Hand

Joined: Apr 01, 2009
Posts: 49
the difference is in encoding
the one in the book is ISO-8...
but i am using UTF-8..
because that one was not working for me , someone suggested me UTF on javaranch..
i told you it was working , the problem started when i used result.jsp
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

The error is in your web.xml, as per the error message:Why do you not believe it? You might *think* it worked before, but I guarantee you it did not. Look at where you define your namespaces:I've edited it to make the error easier to spot. Next time pay attention to the error message, and be careful about making assumptions about what's wrong.
ankur tyagi
Ranch Hand

Joined: Apr 01, 2009
Posts: 49
i am still unable to spot the error...
i have no knowledge of xml all i know is that it is used to map servlet class with
url name..
i copy pasted the code from the book..
if you can elaborate the error you see in the code , it will be nice..please
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

"xmls" is wrong.
ankur tyagi
Ranch Hand

Joined: Apr 01, 2009
Posts: 49
thanks for that..now the error is in the result.jsp file
An error occurred at line: 7 in the jsp file: /result.jsp
List cannot be resolved to a type
same error is returned for iterator and second occurrence of list ...
i figured it out ..
its working now
thanks again
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: calling jsp from servlet