• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

button link to jsp file

 
naveen yadav
Ranch Hand
Posts: 384
Java MyEclipse IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi ranchers ,

i have a main.jsp file. i want the user to get transferd to the register.jsp , if user clicks a button (register).

i have created a button in main.jsp

main.jsp




how can i link this button to register.jsp file so that user can fill up its registration detail.




 
Cole Terry
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65126
92
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Cole Terry wrote:


Almost. Omit the silly "javascript:" prefix. It's not necessary and may fail in some browsers.

And, you should use a server-relative path for the JSP URL rather than a page-relative one. It'll be less fragile.
 
naveen yadav
Ranch Hand
Posts: 384
Java MyEclipse IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

after adding "<button type="button" onclick="javascript:window.location=register.jsp">register</button>" in main.jsp user is not transferred to register.jsp

here is whole code of main.jsp




i have placed the main.jsp and register.jsp in WebContent (Eclipse IDE).

 
Paul Clapham
Sheriff
Posts: 21322
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, that was predictable. What's the URL for your JSP? Don't guess, find out by typing it into your browser's address field.
 
naveen yadav
Ranch Hand
Posts: 384
Java MyEclipse IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator



I have declared the main.jsp in Deployment Descriptor under <welcome> tags because it is the homepage of the application. From there on other jsp page is send as a response depending upon whether user is already a member or a new user(register.jsp).

the url to access main.jsp is : http://localhost:8080/DemoProject_j2ee/
 
Kumaravadivel Subramani
Ranch Hand
Posts: 171
Java Linux Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Then your relative path would be window.location=/register.jsp since application name is not necessary for relative path.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic