1.11M Members

how to call servlet and then jsp

 
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);
}
}
 
0
 

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

 
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>   
 
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

 
0
 

so how do i solve this then

appreciate a reply
thank

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