Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

self generated jsp  RSS feed

 
Lee Dow
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everyone,


My jsp page has this code:

<a href="page<%=er.getCode()%>.jsp"> <%=er.getName()%> </a>

I link to page1.jsp, page2.jsp ... and so on using the primary key field (Code). Now I want page1.jsp, page2.jsp .. to be automatically generated, and what is more, I want each page to contain all data base info related to the Code that names the page.

Any idea of how should I do that? if I should link to a servlet first or something?

Thanks very much
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 37180
515
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Lee,
First of all, I think you would be better served using a single JSP and passing the number/code as a parameter. The JSP (or better yet, a servlet forwarding to a JSP), would get the data and display it in the common format.
 
Lee Dow
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, thanks a lot, you're right it's much less complicated your way.
But I still have a doubt, the servlet (the one that forwards to a jsp) how should read the link with the code I am passing to it??
Could it be something like this:

public static String getUrl(HttpServletRequest req) {
String reqUri = req.getRequestURI().toString();
String queryString = req.getQueryString();
if (queryString != null) {
reqUri += "?"+queryString;
}
return reqUri;
}

Passing the code like this: ..?c=02

Thanks very much again
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 37180
515
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Lee,
You are passing the parameter correctly. To retrieve it:
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving this to the JSP forum...
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!