Win a copy of Java 9 Modularity: Patterns and Practices for Developing Maintainable Applications this week in the Java 9 forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

link url html to jsp  RSS feed

 
Philippe Ponceblanc
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
i have a stupide question !

how you link html page to jsp page, i do it like this but i have error 404.
this my index.html


also
this is the acceuil.jsp
in web.xml


Regards
philippe
 
Mohammed Sardar.
Ranch Hand
Posts: 193
1
Java jQuery Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry for typo. Can you try placing JSP file into a system folder?
 
Philippe Ponceblanc
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mohammed Sardar. wrote:Sorry for typo. Can you try placing JSP file into a system folder?


I want to specify that my file index.html and in the directory "WebContent", while the JSP files are in the subdirectory "webContent / WEB-INF /", I have more JSP here, in fact it is hidden by The "WEB-INF" directory, how can I make the link between index.html and acceuil.jsp?
 
Mohammed Sardar.
Ranch Hand
Posts: 193
1
Java jQuery Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As we discussed in an another thread, We can use a Controller to render the JSP file upon requesting a URL.But in this case if the JSP has to be accessed during run time publicly through a URL then place it out of WEB-INF. Correct the href link path according to the jsp file path.

<a href="test/acceuil.jsp> = > But not inside of another folder in WEB-INF. We can directly specify the path from the project folder. Don't have to show the localhost address. Hope it helps.


 
Philippe Ponceblanc
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mohammed Sardar. wrote:As we discussed in an another thread, We can use a Controller to render the JSP file upon requesting a URL.But in this case if the JSP has to be accessed during run time publicly through a URL then place it out of WEB-INF. Correct the href link path according to the jsp file path.

<a href="test/acceuil.jsp> = > But not inside of another folder in WEB-INF. We can directly specify the path from the project folder. Don't have to show the localhost address. Hope it helps.




If I do as you tell me, that is to say to move acceuil.jsp in WebContent: I have the error 404 of tomcat, I nevertheless modify the web.xml, if I enter the address of home. Jsp in the browser I also have error 404.
 
Paul Clapham
Sheriff
Posts: 22681
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are going to allow your users direct access to your JSPs (which is a bad idea) then you don't have to declare them in web.xml. In fact you should not declare them in web.xml. Tomcat should resolve the JSP exactly the same way it would resolve a JPG file, for example.

But really you shouldn't allow your users to request a JSP directly. Have them access a servlet which sets up request attributes and then forwards to the JSP. The JSP should only have code which formats and displays data from the request attributes, and all other code which decides what data should be sent back to the user and gets that data from databases and so on should be on the controlling servlet.
 
Philippe Ponceblanc
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Paul,
so I understand that for security reasons I can not access to my jsp/servlets of interest to put the JSP in the WEB-INF directory,
but as home page it is necessary to index itself on a file in Html or JSP with a servlet that returns parameters from index.jsp for example.
How to make it simple because my identification with a session scope that is in my acceuil.jsp in the WEB-INF,
can you give me a few lines of codes to put me on the way !
How to declare this servlet in the web.xml ?
 
Mohammed Sardar.
Ranch Hand
Posts: 193
1
Java jQuery Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Servlet will be a Java class and that should be written as a POJO class Plain Old Java Object. This will act as a controller for the requst raised from browser.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66256
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mohammed Sardar. wrote:Servlet will be a Java class and that should be written as a POJO class Plain Old Java Object. This will act as a controller for the requst raised from browser.


By definition, a servlet is not a POJO.
 
Mohammed Sardar.
Ranch Hand
Posts: 193
1
Java jQuery Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:
Mohammed Sardar. wrote:Servlet will be a Java class and that should be written as a POJO class Plain Old Java Object. This will act as a controller for the requst raised from browser.


By definition, a servlet is not a POJO.


Apologies for not using right technical term. Then, Can we say Servlet is a Controller written using Java to dispatch the requests ?. Of Course, servlet does many jobs but mainly acts as a Controller.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66256
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mohammed Sardar. wrote:Can we say Servlet is a Controller written using Java to dispatch the requests ?

No, on two fronts:
  • While a servlet can be a controller it is not limited to controllers.
  • Servlets do not dispatch requests, they service them. (Though of course, you can write code in a servlet to genearate a new request, but that is not a function of the servlet.)


  •  
    Mohammed Sardar.
    Ranch Hand
    Posts: 193
    1
    Java jQuery Spring
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Bear Bibeault wrote:
    Mohammed Sardar. wrote:Can we say Servlet is a Controller written using Java to dispatch the requests ?

    No, on two fronts:
  • While a servlet can be a controller it is not limited to controllers.
  • Servlets do not dispatch requests, they service them. (Though of course, you can write code in a servlet to genearate a new request, but that is not a function of the servlet.)




  • @Bear Bibeault Thanks.
    Despite,  can't edit previous post else it would be  as "Servlet can be a controller but it is not only a controller " .
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!