We're a community of 1.1M IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,080,571 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

how to call servlet and then jsp

hi

what i wan to do is to get the customer ID from the glassfisn database and displaindey it in a drop down box in a jsp page.

in the index.jsp page how to i call the servlet so that the the servlet would load the jsp page?

i have attached the jsp and the servlet page

Attachments CreateVehicleServlet.pdf (103.19KB) AddVehicle.pdf (100.48KB)
4
Contributors
5
Replies
3 Days
Discussion Span
3 Months Ago
Last Updated
24
Views
anisha.silva
Posting Whiz in Training
236 posts since May 2012
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 0

I'm not gonna download files.

But You can do this:

request.getRequestDispatcher("../folder/index.jsp").forward(request, response);

Regarding about drop down box that's pretty interesting you can try this:

@WebServlet("customer")
public class customer extends HttpServlet {

@EJB
private customer service;

@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    List<customer> customer = service.list();
    request.setAttribute("customer", customer);
    request.getRequestDispatcher("../folder/index.jsp").forward(request, response);
}
}
LastMitch
Industrious Poster
4,374 posts since Mar 2012
Reputation Points: 149
Solved Threads: 350
Skill Endorsements: 47

haven't tryied it
will let youknow if it works
thanks

anisha.silva
Posting Whiz in Training
236 posts since May 2012
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 0

do i include the

    request.getRequestDispatcher("../folder/index.jsp").forward(request, response);

in the servlet?

but how do i call a servlet from a jsp page link

<td><a href="Vehicle.jsp"><strong>Vehicle</strong></a>   
anisha.silva
Posting Whiz in Training
236 posts since May 2012
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 0

find the <url_pattern> tag value of your servlet in the web.xml and provide that value/path in the href='your_servlet' tag as shown bellow

<a href="url_pattern_of_your_servlet"><strong>Vehicle</strong></a>

let me know status as well as if you have any doubt in my clarification

happy coding

radhakrishna.p
Posting Whiz in Training
272 posts since Nov 2012
Reputation Points: 29
Solved Threads: 60
Skill Endorsements: 11

so how do i solve this then

appreciate a reply
thank

anisha.silva
Posting Whiz in Training
236 posts since May 2012
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 0

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page generated in 0.0749 seconds using 2.71MB