1,105,416 Community Members

how to call servlet and then jsp

Member Avatar
anisha.silva
Posting Whiz in Training
260 posts since May 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

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)
LastMitch
Deleted Member
 
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);
}
}
Member Avatar
anisha.silva
Posting Whiz in Training
260 posts since May 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

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

Member Avatar
anisha.silva
Posting Whiz in Training
260 posts since May 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
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>   
Member Avatar
radhakrishna.p
Posting Whiz in Training
281 posts since Nov 2012
Reputation Points: 29 [?]
Q&As Helped to Solve: 64 [?]
Skill Endorsements: 11 [?]
 
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

Member Avatar
anisha.silva
Posting Whiz in Training
260 posts since May 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

so how do i solve this then

appreciate a reply
thank

You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: