Hello everyone, I have a question of the following nature:

I have a JSP page with an html form and a Servlet is attached to it. I want a button on a JSP page to have the servlet generate a new page, i.e. creating one more JSP page with the specified information on the forum of the previous page. Can this be done? And what information is best studied for these actions.

I would be very grateful for the directions of studying the correct material. Thank!

Update: In general, I have a ready-made JSP page with a form that contains the following items:

Name (this will be displayed in the page header) URL addresses (this creates the name of the new JSP page) i.e. Here we enter to the privet example, it creates a page for us with the name privet.jsp

Other data.

Create button. By clicking this button, a JSP page will be created from the above data and with the specified URL.

  • describe the process in more detail, preferably with some example;) but it is not very clear what exactly you need - Kobayashi_Maru
  • In general, I have a ready-made JSP page with a form that contains the following elements: Name (this will be displayed in the page header) URL addresses (this creates the name of the new JSP page), i.e. Here we enter to the privet example, it creates a page for us with the name privet.jsp Other data. Create button. By clicking this button, a JSP page will be created from the above data and with the specified URL. - Wengelm
  • Something you are not doing something, or something is not telling us something ... why generate a jsp page? maybe you don't quite understand what jsp is for and what are servlets for? it is quite possible to do without generating the jsp page, - let the servlet return the page in such a way as the jsp that you intend to generate jsp - jmu

3 answers 3

For the model described by you, probably it would be nice to do: * 3 jsp (for the tournament list, for adding one tournament and for editing - if necessary) * 3 servlets (for adding a tournament, for displaying the list and for editing - again if such functionality is required ) no other jsp starstrs should be generated

Threat if you really need to do write on the soap I will help for free, the practice will never hurt

  • In theory, I can do it, i.e. I have already done it, but there are a couple of problems, it would not be bad to consult with you :) And as for the soap from here, it’s not ours to write; ( - Wengelm
  • Soap in profile is - Yury Shadchnev
  • I do not show it :) Maybe some access is limited to view, I do not know. - Wengelm
  • 04pmsuu1 (AT) gmail (dot) com - Yury Shadchnev

Generate another JSP page from a JSP / servlet — this sounds like how to generate another Java source code from Java and run it. Of course, this is sometimes (extremely rare) done. But there must be very good reasons for this.

From what you say, I still do not see why it is needed. For a simple forward, generating JSPs on the fly from one page to another is perhaps too much.

Think carefully - maybe you do not misunderstand something?

  • Maybe I misunderstand. I just have a project to create tournaments on WEB. So, in it the function of creating a tournament. I want it to generate a tournament based on the specified data. But as I do not know, and that for this it is necessary to study. Therefore, I ask here; ( - Wengelm
  • So what? it's hard to reset the HTML generated by keystrokes to the client or to do as explained @ bald2b. Or do you not understand that JSP is further compiled into Java text, which is compiled again into object code and then executed? - Barmaley
  • It turns out I don’t understand why I ask how and where you can find out about it;) - Wengelm
  1. Create another jsp file, say jsp2.jsp
  2. if the button is pressed on the form, then forward to the second jsp file:

    RequestDispatcher dispatcher = getServletContext (). GetRequestDispatcher ("jsp2.jsp"); dispatcher.forward (request, response);

  • a little bit wrong :) - Wengelm
  • one
    Do you need to generate the jsp file? This is of course silly, but possible. Just create the file as usual and save it :) Only the application should have write rights to the folder where the jsp files are located. - bald2b