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

Doubt on calling Servlet from JSP

 
dhwani mathur
Ranch Hand
Posts: 621
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all!!!

i am trying to call a servlet from a JSP....
sorry for such a long post
firstly

i have created a html file as below from which i am
calling JSP.....
trial.html



secondly i have created JSP from which i am calling
a servlet....which is saved in WEB-INF/classes folder
code for Testing.jsp is below




i am calling servlet named test in the
response.sendRedirect() method

here is code for test servlet



changes appropriate to web.xml file have been made
then also i am getting
HTTP STATUS -500
nullpointerException.............


i am trying a lot on it i dont know where i am going wrong


can anyone please help me onto
what is wrong with above code
or any help to solve my problem


it will be of great great help


thanks in advance...............

Dhwani:>Swimmers never weep.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you're getting a NullPointerException, you need to take a look at the server logs to find out where the exception is being thrown.
 
dhwani mathur
Ranch Hand
Posts: 621
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi thr

Thanks for your reply but since i am a beginner
i dont have that much idea onto where
to look for Exceptions please can you ellaborate
and explain the above concept so that i can track
where i am actualy going wrong...........it will
be kinda of you.


Thanks in advance

Dhwani:>Its always too soon to quit.
 
winay Kumar
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

which web server you are using? if you are using tomcat then you can find all server messages in stdout.txt file which inside tomcat/logs/stdout.txt
 
dhwani mathur
Ranch Hand
Posts: 621
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi thr

i am using Tomcat server anyways thansk a lot
my problem is solved but not completly
still i am left with some doubts
actualy first i call html from which i am
calling jsp later i am calling servlet
from jsp using
response.sendredirect() method but
i have put some more coding on my jsp
that i am not getting in my output
i just get the output from my servlet

i mean to say how can i pass my control from
servlet back to jsp so that
i can get output from furthur below jsp code.
i have tried methods like getcontextpath("testing.jsp")
from my servlet but i dont know if
i am in right direction or not

any help on above will be realy great
thanks in advance

Dhwani:>Its always too soon to quit.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure what you're trying to do exactly.
Can you post the relevant parts of your code?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic