• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

problem loading jsp from servlets

 
Ranch Hand
Posts: 187
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi..
i am new to jsp as well as servlets.......

I am trying to connect my servlet with database as well as jsp but i am getting error as class not found since it cannot find REading.jsp file but it is getting connected to the database........
I am not understanding how to debug this code..


the ReadingTable.jsp is as follows


thanks
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

catch(Exception er)
{
System.err.print("ClassNotFoundException: ");
System.err.println(er.getMessage());
}
//response.sendRedirect("/testapp/second.jsp");
}




This code assumes that there's a class not found exception! What's up with that! The exception could be anything.

All this code is doing, is to hide important information. If this is what you are going to do in a catch block, you might as well not have it at all, and just let the exception propagate outward so you can get a decent stack trace and information on the real exception.
 
maggie karve
Ranch Hand
Posts: 187
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yes even though i changed the catch block i am getting........

I am getting ClassNot FoundException...
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Do you not think that showing us the stack trace would be helpful?
 
maggie karve
Ranch Hand
Posts: 187
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
See when i am directing from jsp to servlet...it is going from browser like i put...
from
http:\\localhost:8080\testapp\project1.jsp
to
http:\\localhost:8080\testapp\abc
this is url name of my servlet SimpleExampleServlet.java

and i am getting error on command prompt as

An error occurred at line: 27 in the jsp file: /ReadingTable.jsp
x1 cannot be resolved
24:
25: </tr>
26: <tr>
27: <td><%= request.getAttribute(x1) %></td>
28: <td><%= request.getAttribute(a1) %></td>
29: <td><%= request.getAttribute(b1) %></td>
30: <td><%= request.getAttribute(c1) %></td>


An error occurred at line: 28 in the jsp file: /ReadingTable.jsp
a1 cannot be resolved
25: </tr>
26: <tr>
27: <td><%= request.getAttribute(x1) %></td>
28: <td><%= request.getAttribute(a1) %></td>
29: <td><%= request.getAttribute(b1) %></td>
30: <td><%= request.getAttribute(c1) %></td>
31: <td><%= request.getAttribute(d1) %></td>


An error occurred at line: 29 in the jsp file: /ReadingTable.jsp
b1 cannot be resolved
26: <tr>
27: <td><%= request.getAttribute(x1) %></td>
28: <td><%= request.getAttribute(a1) %></td>
29: <td><%= request.getAttribute(b1) %></td>
30: <td><%= request.getAttribute(c1) %></td>
31: <td><%= request.getAttribute(d1) %></td>
32: <td><%= request.getAttribute(e1) %></td>


An error occurred at line: 30 in the jsp file: /ReadingTable.jsp
c1 cannot be resolved
27: <td><%= request.getAttribute(x1) %></td>
28: <td><%= request.getAttribute(a1) %></td>
29: <td><%= request.getAttribute(b1) %></td>
30: <td><%= request.getAttribute(c1) %></td>
31: <td><%= request.getAttribute(d1) %></td>
32: <td><%= request.getAttribute(e1) %></td>
33: <td><%= request.getAttribute(f1) %></td>


An error occurred at line: 31 in the jsp file: /ReadingTable.jsp
d1 cannot be resolved
28: <td><%= request.getAttribute(a1) %></td>
29: <td><%= request.getAttribute(b1) %></td>
30: <td><%= request.getAttribute(c1) %></td>
31: <td><%= request.getAttribute(d1) %></td>
32: <td><%= request.getAttribute(e1) %></td>
33: <td><%= request.getAttribute(f1) %></td>
34: <td><%= request.getAttribute(g1) %></td>


An error occurred at line: 32 in the jsp file: /ReadingTable.jsp
e1 cannot be resolved
29: <td><%= request.getAttribute(b1) %></td>
30: <td><%= request.getAttribute(c1) %></td>
31: <td><%= request.getAttribute(d1) %></td>
32: <td><%= request.getAttribute(e1) %></td>
33: <td><%= request.getAttribute(f1) %></td>
34: <td><%= request.getAttribute(g1) %></td>
35: <td><%= request.getAttribute(h1) %></td>


An error occurred at line: 33 in the jsp file: /ReadingTable.jsp
f1 cannot be resolved
30: <td><%= request.getAttribute(c1) %></td>
31: <td><%= request.getAttribute(d1) %></td>
32: <td><%= request.getAttribute(e1) %></td>
33: <td><%= request.getAttribute(f1) %></td>
34: <td><%= request.getAttribute(g1) %></td>
35: <td><%= request.getAttribute(h1) %></td>
36: <td><%= request.getAttribute(i1) %></td>


An error occurred at line: 34 in the jsp file: /ReadingTable.jsp
g1 cannot be resolved
31: <td><%= request.getAttribute(d1) %></td>
32: <td><%= request.getAttribute(e1) %></td>
33: <td><%= request.getAttribute(f1) %></td>
34: <td><%= request.getAttribute(g1) %></td>
35: <td><%= request.getAttribute(h1) %></td>
36: <td><%= request.getAttribute(i1) %></td>
37: <td><%= request.getAttribute(j1) %></td>


An error occurred at line: 35 in the jsp file: /ReadingTable.jsp
h1 cannot be resolved
32: <td><%= request.getAttribute(e1) %></td>
33: <td><%= request.getAttribute(f1) %></td>
34: <td><%= request.getAttribute(g1) %></td>
35: <td><%= request.getAttribute(h1) %></td>
36: <td><%= request.getAttribute(i1) %></td>
37: <td><%= request.getAttribute(j1) %></td>
38: <td><%= request.getAttribute(k1) %></td>


An error occurred at line: 36 in the jsp file: /ReadingTable.jsp
i1 cannot be resolved
33: <td><%= request.getAttribute(f1) %></td>
34: <td><%= request.getAttribute(g1) %></td>
35: <td><%= request.getAttribute(h1) %></td>
36: <td><%= request.getAttribute(i1) %></td>
37: <td><%= request.getAttribute(j1) %></td>
38: <td><%= request.getAttribute(k1) %></td>
39: <td><%= request.getAttribute(l1) %></td>


An error occurred at line: 37 in the jsp file: /ReadingTable.jsp
j1 cannot be resolved
34: <td><%= request.getAttribute(g1) %></td>
35: <td><%= request.getAttribute(h1) %></td>
36: <td><%= request.getAttribute(i1) %></td>
37: <td><%= request.getAttribute(j1) %></td>
38: <td><%= request.getAttribute(k1) %></td>
39: <td><%= request.getAttribute(l1) %></td>
40: <td><%= request.getAttribute(m1) %></td>


An error occurred at line: 38 in the jsp file: /ReadingTable.jsp
k1 cannot be resolved
35: <td><%= request.getAttribute(h1) %></td>
36: <td><%= request.getAttribute(i1) %></td>
37: <td><%= request.getAttribute(j1) %></td>
38: <td><%= request.getAttribute(k1) %></td>
39: <td><%= request.getAttribute(l1) %></td>
40: <td><%= request.getAttribute(m1) %></td>
41: <td><%= request.getAttribute(n1) %></td>


An error occurred at line: 39 in the jsp file: /ReadingTable.jsp
l1 cannot be resolved
36: <td><%= request.getAttribute(i1) %></td>
37: <td><%= request.getAttribute(j1) %></td>
38: <td><%= request.getAttribute(k1) %></td>
39: <td><%= request.getAttribute(l1) %></td>
40: <td><%= request.getAttribute(m1) %></td>
41: <td><%= request.getAttribute(n1) %></td>
42: <td><%= request.getAttribute(o1) %></td>


An error occurred at line: 40 in the jsp file: /ReadingTable.jsp
m1 cannot be resolved
37: <td><%= request.getAttribute(j1) %></td>
38: <td><%= request.getAttribute(k1) %></td>
39: <td><%= request.getAttribute(l1) %></td>
40: <td><%= request.getAttribute(m1) %></td>
41: <td><%= request.getAttribute(n1) %></td>
42: <td><%= request.getAttribute(o1) %></td>
43: <td><%= request.getAttribute(p1) %></td>


An error occurred at line: 41 in the jsp file: /ReadingTable.jsp
n1 cannot be resolved
38: <td><%= request.getAttribute(k1) %></td>
39: <td><%= request.getAttribute(l1) %></td>
40: <td><%= request.getAttribute(m1) %></td>
41: <td><%= request.getAttribute(n1) %></td>
42: <td><%= request.getAttribute(o1) %></td>
43: <td><%= request.getAttribute(p1) %></td>
44: <td><%= request.getAttribute(q1) %></td>


An error occurred at line: 42 in the jsp file: /ReadingTable.jsp
o1 cannot be resolved
39: <td><%= request.getAttribute(l1) %></td>
40: <td><%= request.getAttribute(m1) %></td>
41: <td><%= request.getAttribute(n1) %></td>
42: <td><%= request.getAttribute(o1) %></td>
43: <td><%= request.getAttribute(p1) %></td>
44: <td><%= request.getAttribute(q1) %></td>
45: <td><%= request.getAttribute(r1) %></td>


An error occurred at line: 43 in the jsp file: /ReadingTable.jsp
p1 cannot be resolved
40: <td><%= request.getAttribute(m1) %></td>
41: <td><%= request.getAttribute(n1) %></td>
42: <td><%= request.getAttribute(o1) %></td>
43: <td><%= request.getAttribute(p1) %></td>
44: <td><%= request.getAttribute(q1) %></td>
45: <td><%= request.getAttribute(r1) %></td>
46:


An error occurred at line: 44 in the jsp file: /ReadingTable.jsp
q1 cannot be resolved
41: <td><%= request.getAttribute(n1) %></td>
42: <td><%= request.getAttribute(o1) %></td>
43: <td><%= request.getAttribute(p1) %></td>
44: <td><%= request.getAttribute(q1) %></td>
45: <td><%= request.getAttribute(r1) %></td>
46:
47:


An error occurred at line: 45 in the jsp file: /ReadingTable.jsp
r1 cannot be resolved
42: <td><%= request.getAttribute(o1) %></td>
43: <td><%= request.getAttribute(p1) %></td>
44: <td><%= request.getAttribute(q1) %></td>
45: <td><%= request.getAttribute(r1) %></td>
46:
47:
48: </tr>


Stacktrace:
at org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErro
rHandler.java:92)
at org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher
.java:330)
at org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java
:439)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:334)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:312)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:299)
at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext
.java:589)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper
.java:317)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:3
13)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:206)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDisp
atcher.java:646)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(Applica
tionDispatcher.java:436)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationD
ispatcher.java:374)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDis
patcher.java:302)
at myServlets.SimpleExampleServlet.doPost(SimpleExampleServlet.java:95)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV
alve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV
alve.java:191)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(Authentica
torBase.java:465)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j
ava:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j
ava:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal
ve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.jav
a:298)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java
:852)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.proce
ss(Http11Protocol.java:588)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:48
9)
at java.lang.Thread.run(Unknown Source)


i just made changes in servlet code by changing the parameter name
like this
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

An error occurred at line: 27 in the jsp file: /ReadingTable.jsp
x1 cannot be resolved


So what this tell you?

And, do you really think that using variable names like a, b, and c is a good practice?
 
maggie karve
Ranch Hand
Posts: 187
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
it is not recognising my parameters ....
so what should i do???what names shall i put>?
 
maggie karve
Ranch Hand
Posts: 187
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hey i am getting what i wanted

i just changed and put double qoutes in jsp files while receiving parameters....

like

<td><%= request.getAttribute("x1") %></td>
to all the parameters......


BillMonthYear Principal Interest Tax AptRent CarLoan EPB ATT ComcastISP Vonage HealthInsurance CarInsurance PMI BankOfAmerica DCUVISA DiscoverFlag DiscoverMiles TrustVisa HOAFee
54 56454 54 54 54 545464 65 64 64 654 546 5465 4654 6 5465 4654 654 64 64

these are the inputed values which are going to the database as well as getting displayed in my table.........

thanks a lot anyways.......
 
Ranch Hand
Posts: 650
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

maggie joseph wrote:hey i am getting what i wanted

i just changed and put double qoutes in jsp files while receiving parameters....

like

<td><%= request.getAttribute("x1") %></td>
to all the parameters......



That's correct. Think about what it is you need to pass to the request.getAttribute() method. It doesn't want the parameter, it wants the parameter name. A name needs to be quoted. In fact, the x1 variable doesn't even exist in the JSP page.

Finally, you should really not use JSP Scriptlets in your JSP pages (the <% expression %> stuff). Instead, learn to use JSTL (the Java Standard Tag Library).
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic